Inserting Variable Text

From Notepad++ Wiki
Jump to: navigation, search
How to insert text that somehow responds to context?


The Column Editor

Notepad++ comes equipped with a Edit -> Column Editor which can work on a rectangular selection in two different ways:
Coledit.png
  • inserting some fixed text on every line including and following the current line, at the column of the insertion point (aka caret). Initially selected text is left untouched.
  • As the picture illustrates, a linear series of numbers can be inserted in the same manner. The starting value and increment are to be provided. Left padding with zeroes is an option, and the number may be entered in base 2, 8, 10 or 16 - this is how the computed values will be displayed too, padding being based on the largest.

Plugins

Scripting

Notepad++ can run any script engine from its Run -> Run command. The NppExec and RunMe plugin add to this functionality. But, contrary to some other editors, Notepad++ does not have built-in scripting abilities.

Again, some plugins aim to do this, namely SimpleScript (ANSI only) and NppJavaScript. The more specialised Math Plugin would still qualify.

Clipboard

Another route would be to manipulate the clipboard,as a number of functions, not limiting to Paste, make use of the clipboard contents. They are covered in more detail in Clipboard Uses.

Other TextFX tools

Beside the above, TextFX Tools has an Insert line numbers, which inserts line numbers at column 1 for the selected lines, followed by a space.The line numbers are padded with zeroes on the left to be always 8 character long.

Belonging to the same category are the Fill Down Insert and Fill Down Overwrite commands from TextFX Edit. They work on a rectangular selection, take the first row of selected characters and

  • The Insert version inserts this text at the first selected column of the other rows.
  • The Overwrite version simply replaces each selected row of text but the first by the first.

The TextFX -> TextFX Edit -> Insert Clipboard through lines command could be expected to be described here, but is covered in Clipboard Uses, as its use f the clipboard is critical.