Lines And Blocks
Lines are sets of contiguous characters that end with a line terminator. It may occupy several display lines if it is long enough and wraps; otherwise it coincides with a display line. Unless stated otherwise, "line" will refer to the above definition.
What is a line terminator? A couple of special characters, not to be found in normal text and which depend on the OS on/for which the file was made. You can change the line terminator using the Edit -> EOL Conversions -> Convert to Windows / Unix / Mac commands.
Basic line and block operations
|Splitting||Enter, or Sift-Enter||Splits line at curent position, new line is indented|
|Split lines||Ctrl+I||Split the selected lines, or the current line, at the right window edge.|
|Insertion above||Ctrl-Alt-Enter||Inserts new line above current line, new line is not indented|
|Insertion below||Ctrl-Alt-Shift-Enter||Inserts new line below current line, new line is not indented|
|Selection||Triple click, or gutter single click||Make the full pointed line selected|
|Cut line to clipboard||Ctrl+L||Set text clipboard contents to the line contents, and remove the line|
|Copy current line to clipboard||Ctrl+Shift+T||Set text clipboard contents to the line contents|
|Duplicate current line||Ctrl+D||Creates a clon of the current line right below it|
|Move current line up/down||Ctrl+Shift+Up/Down||Exchanges current line with the previous/next line, or the whole selection if it is a single stream|
|Transpose line||Ctrl+T||Exchanges the current line with the previous line. The current line number does not change.|
|Remove empty lines||Remove all lines in active document with no character on them.|
|Remove empty lines (Containing Blank characters)||Remove all lines in active document with no character, or only blanks or spaces, on them.|
|Toggle line bookmark||Ctrl+F2||Toggles whether a line has a #Line bookmark|
|Sort Lines in Ascending Order||Sorts selected lines of active document, in ascending, lexicographic order. Sorts all lines if none selected.|
|Sort Lines in Descending Order||Sorts selected lines of active document, in descending, lexicographic order. Sorts all lines if none selected.|
Most of these commands appear under Edit -> Line commands .
When the line number margin is displayed, clicking on it is equivalent to clicking on any gutter.
|Selection||Single gutter click on start and end lines, or common selection commands||Make a contiguous set of lines eselected|
|Join lines||Ctrl+J||Joins the selected lines together, without intervening seperator|
|Indent / Outdent||Miscellaneous||See Indentation|
|Comment / Uncomment||
|When highlighting a document supports line or block comments, add/remove/toggle line comment marks|
|Hide lines||Alt+H||Hides a selected block, showing its boundaries on margin 1. Clicking on either marker shows lines again, and forgets about their having been hidden.|
|Remove empty lines||Edit → Line Operations||Delete empty lines in all document, regardless of the selected area.|
|Delete blank lines||TextFX Edit||Delete blank lines in the selected block, or in all document|
|Relove Empty lines (Containing blank characters)||Edit → Line operations||Delete lines in the whole document that only contain whitespace characters.|
|Delete surplus blank lines||TextFX Edit||Replace multiple contiguous blank lines by a single blank line, in the selected block, or in all document|
|Split lines at (Clipboard character) or , (VB)||TextFX Edit||Performs the splitting, sparing string litterals|
|Split lines at (Clipboard character) or , (C)||TextFX Edit||Performs the splitting, sparing string litterals|
|Sort lines case sensitive (at column)||TextFX Tools||Sorts the line based on the subsring starting at position n. If a number has been sent as text to clipboard, n is that number. Otherwise, n is 1|
|Sort lines case insensitive (at column)||TextFX Tools||Sorts the line based on the subsring starting at position n. If a number has been sent as text to clipboard, n is that number. Otherwise, n is 1|
|Move Up/Down current line||Ctrl+Shift+Up/Down||Moves current selection up or down; it must be a single contiguous range.|
There is also a macro on commenting the current line, to be found on Useful Macros.
This is a marker, by default a blue bubble, on the margin 1 which can be toggled on and off. You can navigate between bookmarks using Next/Prevvious bookmark. Bu marked lines form a discontinuous block, which you can
- cut to clipboard
- copy to clipboard
- delete unmrked
- replace with clipboard contents
from the Search mennu.
Additionally, you can Bookmarks -> Clear All Bookmarks in a document, or toggle the status of all lines in one sweep using Search -> Bookmarks -> Inverse bookmarks.
Most programming languages support the notion of code block. When Notepad++ detects a keyword or operator that starts a block, it inserts a fold point, which shows on the fold margin.
You can click on such a symbol to fold/unfold the corresponding block. Its first line is always displayed. Ctrl-clicking a folded point will recursively unfold all blocks inside it.
Additionally, the View menu provides the following commands:
- Fold all blocks (Alt-0)
- Unfold all blocks (Alt+Shft+0)
- Fold this block (Ctrl+Alt+F)
- Unfold this block (Ctrl+Alt+Shift+F)
- Fold this block at level n (Alt+n)
- Unfold this block at level n (Alt+Shift+n)
The words "fold" and "collapse" are used interchangeably, and similarly "unfold" and "ucollapse".
Topmost code blocks are said to be at level 1. Their direct sub-blocks are at level 2 and so on. The block level must be a digit between 1 and 8. The default shortcuts use the top keybboard row, not the numeric keypad. Note that the folding block where the current line lies is highlighted on the fold margin. You can change the colour being used using Settings -> Styler Configurator -> Global Styles , Fold active. This will work with the box or circle folding block style only.
The shortcuts for folding and unfolding a level have the same appearace on the Shortcut mapper. However, collapsing commands follow Collapse current level, and likewise for uncollapsing.
Fold state for a document is recorded in session files so as to be restored on reopening the document from the session.
As of version 6.6.6, folding arbitrary text is not supported. Since the Scintilla componnt finds fold points from the lexer for the active language, the lexer would have to somehow support this feature for Notepad++ to provide it.
Creating discontinuous blocks
Even though multiple selections might be expected to appear here, they are discussed in Selection instead.
Besides bookmarks, the following commands from TextFX Viz define hidden/visible blocks based on search results and manipulate them:
- Hide lines without (Clipboard) or All lines
- Hide lines with (Clipboard) or All lines
- Show lines without (Clipboard) or All lines
- Show lines with (Clipboard) or All lines
- Show lines between Selected or All reset lines
- Hide lines between Selected or All reset lines
- Invert visibility between Selected or All lines
- Show more lines around my position
(the names seem decently self-explanatory).
So now, in a selected block, some lines will be hidden and some visible. The following commands allow selective actions on those two sub-blocks:
- Copy visible selection
- Copy invisible selection
- Copy entire selection (no append)
- Copy & Append entire selection
- Cut visible selection
- Cut invisible selection
- Cut entire selection (no append)
- Cut & Append entire selection
- Delete visible selection
- Delete invisible selection
These commands cause Notepad++ to act much alike a spreadsheet as far as lines are concerned.
Rectangular selections are properly taken into account.
TextFX Viz refines the visibility markin of block using the concept of Show/Hide sequence, henceforth referred as "sequence" for short.
TextFX Viz remembers the lines that were just hidden or shown. They are grouped into a sequence. The Insert Show/Hide sequence inserts (exports) a text representation of the current sequence in the following format:
- The exported text is a sequence of lines, each of which is a step;
- The lines are in the order the steps were performed;
- An action is either showing or hiding line rangess
- A show step is denoted as +[start-end]
- A hide step is denoted as -[start-end]
- An inversion step is denoted by ![start-end]
In the above description, start is the lowest line number involved, and end is the highest.
Using Show all between selected or All-reset lines, or switching yo another document and back, resets the current sequence. Sequences can be replayed.
Selecting text in the proper format and using Select as Show/Hide sequence performs the reverse operation and imports the sequence.
When a sequence is being remembered, one way or another, the following commands are applicable:
- Hide/Show sequence all steps - playback sequenc
- Hide/Show sequence singlestep start - ptrpzres to replay sequence step by step
- Hide/Show sequence singlestep next - perform nex step in sequence
- Hide/Show sequence singlestep rest - perform all remaining steps in sequence
- The line at which playback started will never be hidden by the playback
- If the current line lies inside the full block of line being operated on, the sequence may not replay completely. (Is this by design?)