From Notepad++ Wiki
Jump to: navigation, search
How to perform repetitive or multiple tasks in a single swoop?

When working with a text editor, one is bound to be faced with repetitive tasks:

  • change some reference or formatting over a document
  • type the same, or nearly so, short block of text
  • process text patterns hidden inside text you didn't write, like log files
  • end doing something specific when you started doing something specific (like opening/closing a tag for some markup language).

The tools to address such a wide variety of yet related, widespread needs are of four sorts:

  • Canned, repeatable sequences of actions (macros)
  • Getting roadmaps (find/replace)
  • Local action triggered by user (autocompletion, plugin commands)
  • Local automatic actions (bracket autoclose, NppAutoIndent plugin)

It will become apparent that those categories overlap. It is up to the ingenuous user to choose the most appropriate tool. The toolbox is quite large actually.

Canned, repeatable sequences of actions

Basically and in short: macros.

Macros record a sequence of Scintilla messages and Notepad++ vommands, rather than raw keystrokes or only Notepad++ commands. A macro has no parameters, no if statements, soo it cannot adjust to special cases nor be customised at execution time. With this in mind, they can be very efficient.

Macros can be invoked from the Macros menu, or from the shortcut key bound to it, if any. Since they are menu entries, you can add them to the Context Menu for your convenience.

For more details on defining and running a macro, please see Macros.

Roadmaps: find/replace operations

A simple search is an isolated action, and cannot be recorded/replayed safely as it has options. A Find all command will exxplore your document(s) and, with the Mark lines option, define a list of places of interest in your document. This is how they can draw a roadmap.

The offline reference documentation has extensive descriptions for the various types and options of find and replace actions. Please refer to it, this page won't be much better at it. Searching And Replacing provides mostly the same information, but from a different standpoint.

Local actions triggered by user

Very often, this action will be a plugin command. It may offer to provide parameters, or take a more sophisticated action course than a macro, because it is more closely bound to Notepad++ and extends it. Some very common examples:

  • Inserting code snippets (CCompletion, QuickText, ....)
  • Preparing further action (like creating a pair of opening/closing HTML or XML tags (WebEdit, HTML Tag, ...)
  • <Add more examples here>

Local actions triggered automatically

They can be somehow categorised as typing assistance:

  • Bracket autoclose (XBracket Lite, ...)
  • Auto compleion (CCompletion, or Notepad++ internal feature)
  • Auto indenting of code (NppAutoIndent)

More possibilities

Since Notepad++ can run external scripts or programs (NppExec, RunMe, AwkPlugin,...), these automation routes are also available from Notepad++. They can fill some of the gaps left by the above methods.