Macro Language

  • It looks like NPP is missing a very important feature for a code editor, that is, a macro language. I found no way to create a macro by coding, and the macros created by recording are pretty cryptic, and in any case it is not possible to edit them directly but it is necessary to modify an .xlm file. Is there a plugin that allows me to extend NPP by macros that can be edited. For example, I want to create a macro that insert a special Unicode character called “Long S” ( ſ ) in the text. I cannot use a recorded macro because even if I place in clipboard that character and use ctrl-V to insert it, the corresponding recorded macro will not insert THAT character but anything is in clipboard in that moment. Any hints? Thank you in advance.

  • NppExec

    Someone is even working on a Perl Scripting solution (YAY!)

    I’ll let the various experts of each provide more color detail as to “how-to” or maybe you can pick it up yourself if you’re familiar with one of those languages.

    I prefer NppExec myself and use it to extend functionality like an IDE-lite (compile, run, debug for various language types based on extension) but it’s limited compared to the other two - I’m just not that familiar with Lua or Python.


  • @Dario-de-Judicibus said:

    Any hints

    in addition to the scripting language plugins @Michael-Vincent mentioned, there’s also the builtin macros functionality. Unfortunately, the macros doc hasn’t been updated to include all the old macro-config-file details, which would help you understand the format of the file, to be able to craft your own.

    Fortunately, there’s a workaround: record a macro of you typing a letter (say, A), and save the macro under a given name. Restart notepad++ (might be necessary to save the macro into the file), then open %appdata%\notepad++\shortcuts.xml. In the macros section, you’ll find the macro name. Then you’ll notice in one of the macro parameters there’s a "A". Paste your fancy character over that A. Save the file. Exit/reload Notepad++ again. Now your macro should insert the fancy character, rather than A.

    Good luck.

  • The downside of a fully functional macro language is likely that it would be very specific to Notepad++, and then people would argue that it is cryptic and hard to learn. It is better to put one’s efforts into learning Python or Lua for this purpose, then, not only can you use that skill for Notepad++ usages, but also for other tasks.

  • the action type in the recorded message seems to be either 0 or 1, then the message ids follow:
    2170 putchar
    2180 delchar
    2300 down
    2306 getchar
    2326 backspace
    2451 end
    2452 shift-end
    2453 home
    I found that i could combine 2170 type messages with string values, shortening the macro somewhat, making it more readable; it seemed that i could also replace 10 delchars (2180) with " " but that was not consistent.

Log in to reply