-
Details
-
Written by John Button
-
Category: Computing
-
-
-
Hits: 1910
Re-format text blocks to wrap to a fixed character width
- Set the text width in characters
:set textwidth=80
- Select the lines of text you want to re-format
v to use visual selection
- Reformat
gq
- To reformat a single paragraph without selecting it first
{gq}
Turn on (or off) line numbering
- To turn on line numbering, at the : prompt type
set number
- To turn off line numbering, type the command
set nonumber
- To set relative line numbers
set relativenumber
Insert a comment character as the first character in a sequence of lines (i.e., comment a block)
- Position the cursor on the first character in the first line to be commented
- Press Ctrl-
V to enter VISUAL BLOCK mode
- Use arrow keys to select the first character in each line until the last line in sequence
- Press Shift-
I (the i key), which will put the editor in INSERT mode
- Press #, the character to be inserted at the start of each line, note that it will not yet appear on screen
- Press
Esc (wait a couple of seconds), the # character will appear at the start of each line
Remove comment characters from multiple lines
- Assuming # is the comment character, put your cursor on the first # character, press Ctrl-
V
- Use arrow keys to go down until the last commented line, the first character in each line should be highlighted
- Press
x to delete all the selected # characters