One of my favorite feature of Notepad++ is marking a specific word/characters with style. However, whenever I want to mark, I have to manually select that word and mark through a context menu. Instead, since the word that I usually mark is often same and the number of words is limited, is it possible to write a macro - like mark 'AAA' or mark '123' - and assign a shortcut? This would save a lot of time.
问题:
回答1:
A much better approach would be to use Notepad++'s "Define your language" feature available in the menu under Language->Define your language...
Select the "Keywords Lists" tab and you're free to define custom styling for any number of predefined keywords.
Once you're done styling, click "Save As..." and you will be able to find your new "language" under the "Language" menu item.
回答2:
Unfortunately I can not find where my macros are stored. So, I can just provide sequence of actions. For example we want to use 1st Style for "Message sent" and 2nd Style for "Message received":
- Macro -> Start recording
- Search -> Find and search for "Message sent" (as a result "Message sent" is selected)
- Mouse right click on selection -> Style token -> Using 1st Style
- Search -> Find and search for "Message received" (as a result "Message received" is selected)
- Mouse right click on selection -> Style token -> Using 2nd Style
- Macro -> Stop recording
- Save macro
回答3:
I didn't even know about the style marking feature until just but yes it is possible.
To set it up do the following:
- Highlight a word
- Select Macro menu >> Start Recording
- Right click highlighted word and select styletoken and your prefered style
- Select Macro menu >> Stop Recording
- Select Macro Menu >> Save Current Recording Macro
You will the have the option of assigning a shortcut to the macro.
This will mean that all you have to do is highlight the word you want to style and use your shortcut.
If you want to make it a little smarter so that you don't have to highlight the word instead of step 1 just put the cursor anywhere in the word then after you have started recording (step 2) press ctrl and the left arrow once then ctrl + shift and the right arrow to select the word.
And if you want to change the style of all of the words replace step 3 with selecting search >> mark all and your preferred style
回答4:
<Macro name="Highlight" Ctrl="yes" Alt="no" Shift="no" Key="83"> <Action type="1" message="2170" wParam="0" lParam="0" sParam="A" /> <Action type="0" message="2305" wParam="0" lParam="0" sParam="" /> <Action type="2" message="0" wParam="43022" lParam="0" sParam="" /> <Action type="0" message="2180" wParam="0" lParam="0" sParam="" /> </Macro>
The macro does the followings: type "A", select it, highlight it, and delete it. It's very ugly, but does what I wish to do. Anyone has a better idea? I don't want to self-choose my crappy answer :O