• FAQ: Feature Request or Bug Report

    Pinned Locked feature request faq
    1
    3
    10 Votes
    1 Posts
    26k Views
    No one has replied
  • FAQ: Formatting Forum Posts

    Pinned forum format markdown faq
    1
    7
    5 Votes
    1 Posts
    23k Views
    No one has replied
  • FAQ: Template for Search/Replace Questions

    Pinned search replace regex faq
    1
    4 Votes
    1 Posts
    13k Views
    No one has replied
  • FAQ: Logging in to this Forum

    Pinned oauth password notification faq
    1
    4 Votes
    1 Posts
    7k Views
    No one has replied
  • FAQ: Periodic Backup vs AutoSave Plugin

    backup autosave unsaved faq
    3
    1
    3 Votes
    3 Posts
    28k Views
    PeterJonesP
    Corrupted Session Starting in Notepad++ v8.6.5, it will store session.xml.inCaseOfCorruption.bak next to session.xml, and will automatically use that if session.xml is corrupted. However, if you ever find that you open Notepad++ (especially after an update or a system crash) and find that the files opened weren’t in the same state as when you let them, you can try this procedure: Exit Notepad++ Windows Explorer, go to %AppData%\Notepad++ (or in your appropriate config-file location if you aren’t using AppData for config) Rename session.xml to session.xml--keep Copy session.xml.inCaseOfCorruption.bak to session.xml Run Notepad++ → If it’s now showing the right copy of your files, great! If not, exit Notepad++, delete session.xml, and rename session.xml--keep back to session.xml .
  • FAQ: Themes in v8.8.9

    themes v8.8.9 style configurator v8.9
    1
    3 Votes
    1 Posts
    5k Views
    No one has replied
  • FAQ: Using the GCC version of Notpead++

    1
    5
    4 Votes
    1 Posts
    8k Views
    No one has replied
  • 2 Votes
    10 Posts
    24k Views
    PeterJonesP
    Update As of Notepad++ v8.7.6 in January 2025, the Shortcut Mapper should now list the keys based on the keyboard layout that was active when you started Notepad++. You should no longer need this FAQ, unless you are choosing to use an older version of Notepad++.
  • 4 Votes
    2 Posts
    24k Views
    PeterJonesP
    Pork To Sausage The pork2Sausage.ini, accessible through Plugins > Pork to Sausage > Edit user commands, has a number of parameters for use in the the INI definitions, plus two special variables. Parameters: progPath: [Mandatory] The full path of the program to launch This is the full path, including the name of the .exe progCmd: [Mandatory] The whole command to call the program This is the whole command; because the program path is given in the first Parameter, this one can use just the name of the command rather than the full path workDir: [Mandatory] The path of working directory This is needed for setting the “working directory” for the program – for example, if it needs to be able to find specific libraries relative to some “current directory” progInput: [Optional] The full path name of the program input file. Pork to sausage plugin will write the selected text in a new created file with the given full path file name. This is helpful if you don’t want to try to input the “selected text” (see variables, below) on the command line (or example, if the selected text is too long, or the external program doesn’t accept text input on the command line) progOutput: [Optional] The full path name of the program output file. Pork to sausage plugin will replace selected text by the content of indicated file, which is supposed to be the output file of the program. If this parameter is absent, then Pork to sausage plugin will use the stdout of program to replace the selected text. This is useful if the external program writes its output to a file, instead of STDOUT. replaceSelection: [Optional] If its value is false, then the selected text will be untouched. Set this to false if you don’t want the active selection in Notepad++ to be overwritten. Variables $(SELECTION): Your text selection. The text will be encoded as UTF16-LE. Your external command must be able to handle the text in that encoding. $(TIMESTAMP): the Timestamp which will be generated by Pork to Sausage at the start of the call. This varible used for naming the file created by Pork to sausage plugin (progInput) to ensure the unicity (uniqueness) of the created file. Discussion There are two primary input methods to your application. You can send the selected text as an argument on the command line:progCmd=external.exe -inText "$(SELECTION)" ... You can have Pork to Sausage create a temporary file containing the selection:progInput=%TEMP%\Pork2Sausage.$(TIMESTAMP).input progCmd=external.exe -inputFile "%TEMP\Port2Sausage.$(TIMESTAMP).input" Example The default pork2sausage.ini gives a couple of examples of using just the command-line for the input text and the STDOUT of the command as the output text. But to give an example which requires the selected-text be sent to a temporary file (progInput) and the output of the command to another file (progOutput), here is a version of the same action as used by the NppExec example from earlier: [gpg-decrypt selection to self] progPath=c:\usr\local\apps\gnupg\bin\gpg.exe progCmd=gpg --output "C:\Users\XYZ\AppData\Local\Temp\p2s.$(TIMESTAMP).output" --decrypt "C:\Users\XYZ\AppData\Local\Temp\p2s.$(TIMESTAMP).asc" progInput=C:\Users\XYZ\AppData\Local\Temp\p2s.$(TIMESTAMP).asc progOutput=C:\Users\XYZ\AppData\Local\Temp\p2s.$(TIMESTAMP).output workDir=C:\Users\XYZ\AppData\Local\Temp The selected text will be written to the progInput file. Then progCmd will be run, which decrypts from the same file as progInput, and puts the result in the same file as progOutput. Then the plugin replaces the selected text with the contents of the progOutput file.
  • FAQ: Automating Notepad++

    faq macros scripting automation
    2
    6 Votes
    2 Posts
    15k Views
    PeterJonesP
    SubFAQ: Using Plugin, Run-menu and Macro Commands in Macros Plugin commands (even for the default plugins, like MIME Tools) are not macro-recordable; neither are Run-menu commands, or other Macros. However, with a bit of effort on your part, they can be macro-playable (with some limitations). The reason that they aren’t macro-recordable is that macros make use of the menu command ID for storing which command to use. For built-in menu commands, those commands all have a fixed ID, so from one run of Notepad++ to the next, they will always keep the same menu command ID. Since the plugins available and taking up menu space can be different from run-to-run in Notepad++, the application actually assigns the menu command IDs for each plugin dynamically (stored Run menu commands and saved Macros, similarly, get a dynamically-allocated command ID). Thus, if you install or upgrade a plugin such that the number of plugin menu commands change, the next time you run Notepad++, other plugins will possibly get different command IDs compared to the previous run (depending on what order Notepad++ processes each of the plugins). Due to this dynamic menu command ID, Notepad++ would not be able to guarantee that a command ID it records for the macro would work for the same command the next time Notepad++ is run, and thus does not record plugin commands, saved Run-menu actions, or other Macro commands. There are two workarounds (which will work on Plugin commands, saved Run-menu commands, and running other Macros): Use a scripting plugin (like PythonScript) instead of Macros to do your automation (because scripting plugins usually have helper commands that can search through the menu to be able to run even plugin menu commands). This adds overhead, and you might have to learn a new programming language, but it gives you a lot more power. Cheat the macro system. This will be described below, but has the downside that you have to manually edit the macro XML, and you might have to tweak it if you install or upgrade plugins. How to Cheat the Macro System As I said earlier, the macros are dynamic, depending on the order that Notepad++ processes the plugins and how many menu commands each plugin uses. However, for any stretch of time where you don’t install any new plugins or upgrade existing plugins, Notepad++ will process your plugins in the same order, so they will get the menu command IDs for each run. So to cheat the macro, you can snoop to find the current menu command ID for each action, then manually edit the macro’s XML, then restart Notepad++, and the macro should work until the next time you install or update a plugin. Let’s assume that you want to have a macro that will Select All, then Plugins > MIME Tools > Base64 Encode with Padding, then Select All, then Copy the results to the clipboard. (inspired by this discussion). Record this sequence and save it as RecordedMacro with no assigned keyboard shortcut. (Just for this example; the names and shortcuts are obviously up to you for your real task.) To snoop the menu command ID, I recommend the NppUISpy plugin. So install that plugin, then run it’s Spy! command (either from its menu or toolbar icon). For example, with my current plugins, Spy! tells me that Base64 Encode with Padding is Command Id = 22064 Open %AppData%\Notepad++\shortcuts.xml and edit your recorded macro. It would start out as something like this:<Macro name="RecordedMacro" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="0" message="2013" wParam="0" lParam="0" sParam="" /> <Action type="0" message="2013" wParam="0" lParam="0" sParam="" /> <Action type="0" message="2178" wParam="0" lParam="0" sParam="" /> </Macro> That is the Select All command twice and the copy (skipping the plugin command between the two Select All. You would need to edit it to be like:<Macro name="RecordedMacro" Ctrl="no" Alt="no" Shift="no" Key="0"> <Action type="0" message="2013" wParam="0" lParam="0" sParam="" /> <Action type="2" message="0" wParam="22064" lParam="0" sParam="0" /> <Action type="0" message="2013" wParam="0" lParam="0" sParam="" /> <Action type="0" message="2178" wParam="0" lParam="0" sParam="" /> </Macro> which puts the 22064 that I found with NppUISpy in between the two Select All instances. Please note that many recorded editor commands (like copy, paste, home, etc) will be type="0" with the scintilla command in the message="..." field; whereas menu commands like the plugin command will be type="2" and put the menuCommandID into the wParam="###" field. See the user manual’s <Macro><Action> details for more. Save the shortcuts.xml and restart Notepad++. At this point, running your macro should do the select all, the conversion, the select all, and the copy. The next time you installed or upgraded a plugin, you would need to re-run Spy!, and check whether the command ID has changed; if it has, edit shortcuts.xml again, and replace the example 22064 with the new number. (If your macro involves another macro or a run menu command, you will also have to re-check the command ID using Spy! or equivalent: adding plugins , removing plugins, or sometimes even upgrading plugins will change the command IDs for plugin commands; similarly, adding or deleting macros can change the command IDs for other macros; and adding or deleting saved Run menu entries can change the command IDs for other saved Run menu entries.)
  • FAQ: Why Can't I Just Say "Most Recent Version"

    faq most recent version
    1
    5 Votes
    1 Posts
    6k Views
    No one has replied
  • FAQ: How do I create a Poll in the Forum?

    Moved faq
    3
    2
    1 Votes
    3 Posts
    8k Views
    PeterJonesP
    @Mark-Olson , Moved.
  • FAQ: Parsing and Editing JSON with regex is a bad idea

    faq json regex
    2
    3 Votes
    2 Posts
    13k Views
    PeterJonesP
    Corollary: Parsing and Editing XML or HTML with regex is also a bad idea For essentially the same reasons. More on the horrors of HTML and regex can be found in this Stack Overflow answer. For working with XML and similar markups in Notepad++, the plugin XMLTools is an excellent choice as the first line of attack, and using one of the scripting plugins (like PythonScript, LuaScript, or jN) and the XML libraries that are appropriate to that programming language will allow you to tackle the more complicated problems.
  • FAQ: Can I Do a Mathematical Replacement?

    faq math replacement regex add1
    4
    5 Votes
    4 Posts
    16k Views
    PeterJonesP
    MultiReplace Plugin The MultiReplace Plugin is another plugin that will allow replacements to use mathematical forumula. Starting in Notepad++ v8.5.8, you can install the plugin through Plugins Admin. For older versions of Notepad++, you may be able to install it manually. As explained in this post, this is in a nutshell how MultiReplace is working for Math. Activating ‘Use Variables’: This option facilitates math functions and dynamic string substitutions within a Replace String. It can work with all search settings combined and is not exclusively dependent on regex. Commands Overview: Either set or cond command is mandatory to set in ‘Replace with’ to wrap the math functions. set(strOrCalc) - simple push of math results to Replace cond(condition, trueVal, [falseVal]) - if-then or if-then-else condition for push of results Examples of Commands Usage: set("replaceString"..CNT) - results in “replaceString3” (assuming CNT = 3). set(LINE+5) - results in “10” (assuming LINE = 5). cond(LINE<=5 or LINE>=9, "edge", "center") - results in “edge” (assuming LINE = 5). cond(LINE<3, "Modify this line") - Keeps original text if condition is false (assuming LINE >= 3). Variables Overview: (will be enhanced in future by User requests): CNT: Count of the detected string. LINE: Line number where the string is found. APOS: Absolute character position in the document. LPOS: Relative line position. LCNT: Count of the detected string within the line. COL: Column number where the string was found (CSV-Scope option selected). MATCH: Contains the text of the detected string. Special Variables: CAP1, CAP2, …: Correspond to regex capture groups $1, $2. CAP variables are usable for calculations or as strings. Format Handling: If the CAP variable is a number it can interpret both dot and comma as decimal separators, making international usage more straightforward. Thousand separators are not supported. Note: $1 and $2 can be used in ReplaceString but content will only be resolved in CAP Variables for conditions and math functions Example of special Variables: Find: (\d+.\d+) Replace with: set(CAP1 * 1.2) - multiplies decimal number with 1.2 Basic rules: Strings have to be quoted by ' or " Concatenation is by .. Arithmetic: +, -, *, /, ^, % Relational: ==, ~=, <, >, <=, >= Logical: and, or, not Example of combining: Find: Price: (\d+(\.\d+)?) Replace with: cond(CAP1~=0, "Price per unit: " ..(CAP1/10), "Price cannot be zero") - Calculates Price per Unit if not Zero. Further functionality: As the engine is LUA driven all LUA math and string functions can be used in set or either cond Example with advanced math Function: Find: Radius: (\d+) Replace with: set("Circumference: "..(2 * math.pi * CAP1)) - Calculates the circumference of a circle given its radius. Example with a string function for alignment: Find: ; Replace with: cond(LCNT == 1, string.rep(" ", 20 - (LPOS))..";") - aligns first occurrence of semicolon in Line to the 20th character position.
  • FAQ: I Cannot Find My Panel!

    search results find all results panels faq
    1
    4
    6 Votes
    1 Posts
    9k Views
    No one has replied
  • 4 Votes
    1 Posts
    12k Views
    No one has replied
  • 6 Votes
    1 Posts
    20k Views
    No one has replied
  • FAQ: Validating Config-File XML

    faq xml validation config-files config
    1
    3 Votes
    1 Posts
    19k Views
    No one has replied
  • FAQ: New Change History feature

    faq change history orange bar
    1
    2
    4 Votes
    1 Posts
    38k Views
    No one has replied
  • FAQ: How do I Replicate the Features of TextFX?

    faq textfx
    1
    3 Votes
    1 Posts
    16k Views
    No one has replied