Alt+l+x tag is not adding in macro
-
I started a macro and align the text and want to format the content to xml at the end of the macro. I stopped the macro. while I Playback the macro it performs all the activities which I have done except formatting the content to XML. Please help.
-
@vijay-S ,
If I understand you correctly, you would like to set the file to XML at the end of your macro. You are correct, the Language menu’s XML entry does not get recorded when you record a macro (there are many menu entries that do not record correctly, for a variety of reasons). However, if you are willing to manually edit the macro after you record it, you may add that command to the macro.
Per https://npp-user-manual.org/docs/config-files/#macros , you can look at the
IDM_...
values in menuCmdID.h in the source code to find wParam values fortype="2"
actions. TheIDM_LANG_XML
action resolves to a value of46006
. When you include that in the macro, then it changes the language to XML, just like that menu entry.- Record and save your macro (if this is already done, move on to step #1)
- Close all instances of Notepad++
- Open one single instance of Notepad++
- File > Open
%AppData%\Notepad++\shortcuts.xml
- Search for the name of your macro. In my case, I used
npp19956
(after the topic number in the URL)<Macro name="npp19956" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="0" 1message="2316" wParam="0" lParam="0" sParam="" /> </Macro>
- Add
<Action type="2" message="0" wParam="46006" lParam="0" sParam="" />
to the end of the Macro<Macro name="npp19956" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="0" message="2316" wParam="0" lParam="0" sParam="" /> <Action type="2" message="0" wParam="46006" lParam="0" sParam="" /> </Macro>
- Save
shortcuts.xml
- Exit the Notepad++ application
- Run a new instance of Notepad++.
The Macro should now have a last action to change the language to XML, just like the Language > XML menu entry.
-
@PeterJones said in Alt+l+x tag is not adding in macro:
File > Open %AppData%\Notepad++\shortcuts.xml
``
File > Open %AppData%\Notepad++\shortcuts.xmlI am not seeing the file
Instead I saw
%AppData\Roaming\Notepad++\shortcut.xml . But I am not find my save macro
there``
-
@PeterJones said in Alt+l+x tag is not adding in macro:
Add <Action type=“2” message=“0” wParam=“46006” lParam=“0” sParam=“” /> to the end of the Macro
``
Please ignore this. I found the xml in other path and it works like a charm
``
-
``
can you tell me the reason why it was not working without adding the additional entry and how can we fix for other issue… is there any tutorial
``
-
@vijay-S said in Alt+l+x tag is not adding in macro:
I am not seeing the file
Instead I sawAppData\Roaming\Notepad++\shortcut.xml
That’s because you didn’t type (or paste) the text I wrote; instead, you manually navigated and thought I meant
AppData
when i said%AppData%
.%AppData%
is an environment variable, explained more in this FAQ.can you tell me the reason why it was not working without adding the additional entry
I told you as much as I know for the “why”: “there are many menu entries that do not record correctly, for a variety of reasons”
- official docs: macro overview = https://npp-user-manual.org/docs/macros/
- official docs: macro syntax in
shortcuts.xml
= https://npp-user-manual.org/docs/config-files/#macros
-
`` one more
I have a single line big xml. I want to format in xml. I want to do this without downloading TExtFX or XMl tools plugin.
is there any way
``
-
@vijay-S said in Alt+l+x tag is not adding in macro:
I want to format in xml.
I suppose you start by defining what kind of formatting you want to do.
-
@vijay-S said in Alt+l+x tag is not adding in macro:
I have a single line big xml. … without downloading TExtFX or XMl tools plugin.
is there any wayNotepad++ does not have any native XML formatting tools built in.
I understand that having XML (or HTML, or any other code) all on a single line with no line breaks can be annoying.
There are two good ways and a bad way to format XML (or any other code), and a fourth way that is really just a lame workaround:
- Download a plugin that already handles it, like XML Tools.
- You have rejected this without giving a reason, even though this is the best answer to give you
- Note: TextFX hasn’t been maintained in years, and thus hasn’t kept up-to-date with modern Notepad++. I wouldn’t recommend that route.
- Download a tool unrelated to Notepad++ which will give you an external
.exe
file which will format your XML for you.- This is better than nothing, but not as convenient as having it in a Notepad++ plugin
- @Michael-Vincent has posted that he uses
tidy5
for XML, and runs that (and other code tidy apps) using an NppExec script shared in another post. Of course, that also involves a plugin, so even though it’s another good suggestion, you are likely to reject it.
- Do a poor-man’s “xml tidy”, which just involves splitting at the end
>
of every XML tag.- FIND =
>
, REPLACE =>\r\n
will put a newline after ever>
- This will not do any fancy indenting
- If you want fancy indenting, use a tool developed for the job, like the XML Tools plugin or
tidy5
or whatever other external tool you want
- FIND =
- Workaround: Turn on word-wrap, and Notepad++ will at least visually wrap, so you can change the width of your editor window to decide how many characters will be shown per “line”. Please note that this doesn’t change the underlying XML, so that will still all be one big long line.
Rejecting pre-made and already-debugged solutions will only hurt you and the quality of your work. Thinking that we will re-invent the wheel for you, just because you don’t happen to like a particular brand of tire, could be considered rather selfish. I recommend using suggestion #1 or #2. Good luck.
- Download a plugin that already handles it, like XML Tools.