在记事本中双击捕获 PHP 变量 ++

发布于 10-19 00:30 字数 136 浏览 12 评论 0原文

我刚刚从 eclipse 切换到 Notepad++ 并修改了记事本的一些行为,但仍有一个未解决: 当我双击一个变量时,我希望我的编辑器能够捕获整个变量。 记事本自动排除 php 前缀“$”,效率不高。 有什么办法可以改变我的行为吗?

谢谢

I just switched from eclipse to Notepad++ and I modified some behaviour of notepad, but there is still one not resolved :
When I double-click on a variable I expect my editor to catch the entire variable.
Notepad excludes automatically the php prefix "$", that is not efficient.
Is there a way I can change the behaviour ?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

扶醉桌前2024-10-26 00:30:29

从版本 7.3.1(2017 年 1 月 17 日发布)开始,他们添加了一种简单的方法来执行此操作。引用发行说明

此版本中添加了自定义 Word 字符的增强功能:双击选择或使用“仅匹配整个单词”选项进行搜索时,所选字符将停止在非单词字符上。 通过此增强功能,用户可以将任何非单词字符包含到单词字符集中,以更改其默认行为。

要启用它,请转到“设置”->“首选项->分隔符,选择“将字符添加为单词的一部分”,然后在文本框中添加美元符号 ($)。关闭就可以了!

As of version 7.3.1 (released on 17 Jan 2017) they have added a simple way of doing this. Quoting from the release notes,

An enhancement for customizing of Word characters is added in this version: While double-clicking to select or searching with "Match whole word only" option, the selected characters stop on non-word characters. With this enhancement, users can include any non-word character into word character set, in order to change its default behaviour.

To enable it, go to Settings -> Preferences -> Delimiter, choose "Add your character as part of your word", and add a dollar sign ($) in the text box. Close and it works!

苍风燃霜2024-10-26 00:30:29

以下是如何使用 Alt + 单击在 Npp 中选择整个 $php_variable / $word,包括“$”符号:

编辑: 我现在意识到您可以请跳过 Npp 宏并仅使用 AutoHotKey 执行此操作。但无论如何我都会保留这个宏,以防万一 smb 喜欢它。有关更多详细信息,请查看 AutoHotkey.chm,在内容选项卡中导航至:Kheyboard Control >>> Send/SendRaw...

不要在 {LButton}{...} 之间放置空格,否则它们将被插入到编辑器中(逗号后面的空格似乎可以)。

它可能会是这样的(还没有测试过)。

!LButton::
Send, {LButton}{CTRLDOWN}{LEFT}{CTRLUP}{LEFT}{CTRLDOWN}{SHIFTDOWN}{RIGHT}{RIGHT}{SHIFTUP}{CTRLUP}
return

结束编辑

我终于在 Autohotkey 的帮助下完成了这项工作

  • (谷歌搜索)。
  • npp 宏

宏:

  • 在开始记录宏之前:单击 php 变量内部,以便闪烁的光标位于其中(例如:$php_varia|ble
  • 现在点击记录宏,
  • 现在按:Ctrl+左,左(无ctrl),ctrl+shift+右,ctrl+shift+右;这将选择整个 php 变量/单词,包括“$”
  • 停止宏记录,然后:“保存当前记录的宏”。为其分配键盘快捷键(我分配了 Ctrl + Alt + Shift + B)

Autohotkey 脚本:

; alt + click translated to Click followed by Ctrl Shift Alt B
!LButton::
Send, {LButton}{CTRLDOWN}{SHIFTDOWN}{ALTDOWN}b{ALTUP}{SHIFTUP}{CTRLUP}
return

现在,当您 Alt + 单击 NPP 中的 php 变量时,它将选择所有变量,包括“$”符号。

我还有通过 Ctrl + LMouseBtn / Ctrl + Shift + LMouseButton / Ctrl + RMouseButton 进行复制/剪切/粘贴的脚本:

^RButton::
Send, {CTRLDOWN}v{CTRLUP}
return

^LButton::
Send, {CTRLDOWN}c{CTRLUP}
return

^+LButton::
Send, {CTRLDOWN}x{CTRLUP}
return

; the plus sign means the Shift key, etc
; see 'Keyboard control' >> 'Hotkeys and Hotstrings' in the Autohotkey help.chm

Here is how you can select the whole $php_variable / $word in Npp, including the '$' sign, with Alt + Click:

EDIT: I realize now that you can do skip the Npp macro and do it only with AutoHotKey. But I'll leave the macro anyway in case smb likes it. For more details look into the AutoHotkey.chm, in the contents tab, navigate to: Kheyboard Control >> Send/SendRaw...

Do not put spaces between the {LButton}{...} or they will be inserted into the editor (the space after the comma seems ok).

It would probably go something like this (havent tested it).

!LButton::
Send, {LButton}{CTRLDOWN}{LEFT}{CTRLUP}{LEFT}{CTRLDOWN}{SHIFTDOWN}{RIGHT}{RIGHT}{SHIFTUP}{CTRLUP}
return

END EDIT

I have finally done this with the help of

  • Autohotkey (google it).
  • npp macro

The macro:

  • before you start to record the macro: click inside a php variable so that the blinking cursor is inside it(eg: $php_varia|ble)
  • now hit record macro
  • now press: Ctrl+left, left(no ctrl), ctrl+shift+right, ctrl+shift+right; This will select the whole php variable / word, including the '$'
  • stop the macro record, then: 'Save Current Recorded Macro'. Assign to it a keyboard shortcut (I assigned Ctrl + Alt + Shift + B)

The Autohotkey script:

; alt + click translated to Click followed by Ctrl Shift Alt B
!LButton::
Send, {LButton}{CTRLDOWN}{SHIFTDOWN}{ALTDOWN}b{ALTUP}{SHIFTUP}{CTRLUP}
return

Now when you Alt + Click on a php variable in NPP it will select all of it, including the '$' sign.

I also have script for Copy / Cut / Paste by Ctrl + LMouseBtn / Ctrl + Shift + LMouseButton / Ctrl + RMouseButton:

^RButton::
Send, {CTRLDOWN}v{CTRLUP}
return

^LButton::
Send, {CTRLDOWN}c{CTRLUP}
return

^+LButton::
Send, {CTRLDOWN}x{CTRLUP}
return

; the plus sign means the Shift key, etc
; see 'Keyboard control' >> 'Hotkeys and Hotstrings' in the Autohotkey help.chm
烙印2024-10-26 00:30:29

我理解您的问题,但不幸的是,Notepad++ 无法设置此行为。

您可以做的就是在美元符号和变量名称之间单击。然后,只要美元符号之前没有特殊字符(例如 [$var]),您就可以获取整个变量。

I understand your problem, but unfortunately it is not possible with Notepad++ to setup this behaviour.

What you can do is click between the dollar sign and the variable name. Then you will grab the whole variable as long as there is no special character before the dollar sign (for example [$var]).

舞袖。长2024-10-26 00:30:29

我创建了一个宏,它写入 $ ,然后将其粘贴到剪贴板中,然后为该宏分配一个快捷方式 ctr+alt +v

I've created a macro that writes $ and then paste whatever it is in the clipboard, then assigned a shortcut to that macro ctr+alt+v.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文