notepad++ mark style with macro

匿名 (未验证) 提交于 2019-12-03 08:28:06

问题:

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":

  1. Macro -> Start recording
  2. Search -> Find and search for "Message sent" (as a result "Message sent" is selected)
  3. Mouse right click on selection -> Style token -> Using 1st Style
  4. Search -> Find and search for "Message received" (as a result "Message received" is selected)
  5. Mouse right click on selection -> Style token -> Using 2nd Style
  6. Macro -> Stop recording
  7. 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:

  1. Highlight a word
  2. Select Macro menu >> Start Recording
  3. Right click highlighted word and select styletoken and your prefered style
  4. Select Macro menu >> Stop Recording
  5. 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



转载请标明出处:notepad++ mark style with macro
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!