PHP variable capture with double click in Notepad ++

I just switched from eclipse to Notepad ++ and I changed some kind of notepad behavior, but still one is not allowed: When I double click on a variable, I expect my editor to catch the whole variable. Notepad automatically excludes the php "$" prefix, which is inefficient. Is there a way to change the behavior?

thanks

+6
variables php notepad ++ behavior
source share
4 answers

I understand your problem, but unfortunately Notepad ++ cannot configure this behavior.

What you can do is click the dollar icon and the variable name. Then you grab the entire variable until there is no special character in front of the dollar sign (for example, [$var] ).

+3
source share

Starting with version 7.3.1 (released January 17, 2017) they have added an easy way to do this. Quoting from the release notes ,

In this version, an improvement has been added for customizing Word characters: when you double-click to select or search with the option "Only match the whole word", the selected characters stop at characters other than words. With this enhancement, users can include any character without a word in the character set of the word to change its default behavior.

To enable it, go to "Settings" → "Settings" → "Separator", select "Add your character as part of your word" and add a dollar sign ( $ ) in the text box. Close and it works!

+5
source share

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

EDIT: Now I understand that you can skip the Npp macro and only do this with AutoHotKey. But I still leave the macro if someone likes it. For more information, see AutoHotkey.chm, on the content tab, go to: Kheyboard Control → Send / SendRaw ...

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

It will probably look like something similar (havent checked it out).

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

End edit

I finally did it with

  • Autohotkey (google it).
  • npp macro

Macro:

  • before you start recording a macro: click inside the php variable so that it contains a blinking cursor (for example: $php_varia|ble )
  • now gets into the recording macro
  • now press: Ctrl + left, left (without Ctrl), ctrl + shift + right, ctrl + shift + right; This will select the entire php variable / word, including '$'
  • stop the macro recording, then: "Save the current recorded macro." Assign it a keyboard shortcut (I assigned Ctrl + Alt + Shift + B)

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 that you have Alt + click on the php variable in NPP, select all of it, including the $ sign.

I also have a script to copy / cut / paste with 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 
+3
source share

I created a macro that writes $ , and then paste everything that is on the clipboard, then assigned a shortcut for this macro ctr + alt + v .

+2
source share

All Articles