I would like to write a macro for Notepad++ which should replace char1, char2, char3 with char4, char5, char6, respectively. Thanks
相关问题
- I want to trace logs using a Macro multi parameter
- Solaris and Preprocessor Macros
- Fixing Markdown styling in Notepad++
- integer to word conversion in java using map conti
- What does “macro annotations embedding in comments
相关文章
- Macro expansion in elixir: how to define 2 macros
- How to import macros in Rust?
- Using C Preprocessing to get integer value of a st
- Using UNREFERENCED_PARAMETER macro
- What is “3D syntax”?
- How do I write a macro-defining macro in common li
- Disabling drag-and-drop of text in Notepad++
- How can I do a non greedy regex query in notepad++
This post can help you as a little bit related :
Using RegEX To Prefix And Append In Notepad++
Assuming alphanumeric words, you can use:
Search = ^([A-Za-z0-9]+)$ Replace = able:"\1"
Or, if you just want to highlight the lines and use "Replace All" & "In Selection" (with the same replace):
Search = ^(.+)$
^ points to the start of the line. $ points to the end of the line.
\1 will be the source match within the parentheses.
My personal experience is that shortcuts.xml is overwritten with the initially loaded + later recorded macros and settings when Notepad++ exits. So you can't use Notepad++ itself for editing this file.
Close Notepad++, edit shortcuts.xml by another tool, save it and restart Notepad++.
I recorded a macro and I found it in %APPDATA%\Notepad++\shortcuts.xml. It looks like posted in the first post of this thread.
I use NPP Ver. 5.9.6.2 with Win7.
Macros in Notepad++ are just a bunch of encoded operations: you start recording, operate on the buffer, perhaps activating menus, stop recording then play the macro.
After investigation, I found out they are saved in the file shortcuts.xml in the Macros section. For example, I have there:
I haven't looked at the source, but from the look, I would say we have messages sent to Scintilla (the editing component, perhaps type 0 and 1), and to Notepad++ itself (probably activating menu items).
I don't think it will record actions in dialogs (like search/replace).
Looking at Scintilla.iface file, we can see that 2170 is the code of ReplaceSel (ie. insert string is nothing is selected), 2327 is Tab command, and Resource Hacker (just have it handy...) shows that 42024 is "Trim Trailing Space" menu item and 41006 is "Save".
I guess action type 0 is for Scintilla commands with numerical params, type 1 is for commands with string parameter, 2 is for Notepad++ commands.
Problem: Scintilla doesn't have a "Replace all" command: it is the task of the client to do the iteration, with or without confirmation, etc.
Another problem: it seems type 1 action is limited to 1 char (I edited manually, when exiting N++ it was truncated).
I tried some tricks, but I fear such task is beyond the macro capabilities.
Maybe that's where SciTE with its Lua scripting ability (or Programmer's Notepad which seems to be scriptable with Python) has an edge... :-)
[EDIT] Looks like I got the above macro from this thread or a similar place... :-) I guess the first lines are unnecessary (side effect or recording) but they were good examples of macro code anyway.
I'm not sure if this helps, but I needed to create a macro to hold a snippet, so I simply recorded myself inserting the items and set a shortcut to it. Granted, I'm not using version 5.9 so there might be some slight version differences. To access the macro recorder go to Macro > Start Recording. Then you will perform your action and then go to Macro > Stop Recording. I'd recommend playing it back to ensure it's correct and then save and set your shortcut key.
Hope the helps.
Actually, the shortcuts.xml file does not store user-generated macros and no obvious candidates contain this info. These instructions are out of date.
Contrary to various websites' tips, storing user-generated macros isn't enabled for v.5.4.2. That XML file is there, but your macro does not get stored it in.
I'm guessing it's a bug that'll be fixed by the next version.