How do I create a macro that uses an incrementing counter?
Use :let i=1 with macro
By combining a Vimscript variable with a macro, you can create sequences with incrementing numbers.
Use :let i=1 with macro
By combining a Vimscript variable with a macro, you can create sequences with incrementing numbers.
"=2+3<CR>p
The expression register = evaluates a Vimscript expression and stores the result.
"ap, edit, "add
Since macros are stored in registers, you can paste the register content into the buffer, edit it, and yank it back.
U (in visual mode)
In visual mode, pressing U converts all selected text to uppercase.
y (in visual mode)
In visual mode, pressing y yanks (copies) the selected text into the default register.
c""<Esc>P
Without a surround plugin, you can manually wrap selected text by changing it, typing the delimiters, and pasting the original text back.
<C-v>jjjg<C-a>
Selecting a column of identical numbers with visual block mode and pressing g turns them into an incrementing sequence.
u (in visual mode)
In visual mode, pressing u converts all selected text to lowercase.
visual select + d, move, P
To swap two pieces of text, delete the first selection, navigate to the second, select it, and paste.
>
In visual mode, pressing > indents all selected lines by one shiftwidth.
J (in visual mode)
In visual mode, pressing J joins all selected lines into a single line with spaces between them.
<C-v>selection r{char}
In visual block mode, pressing r followed by a character replaces every character in the selected rectangle with that character.
<C-v>jj$A
Combining visual block mode with $ and A lets you append text at the end of multiple lines, even when the lines have different lengths.
<C-v>selection c
In visual block mode, pressing c changes (replaces) all the text in the selected rectangle.
<C-v>jjI1. <Esc>
Visual block insert can add numbered prefixes to lines.
y$
The y$ command yanks (copies) text from the cursor position to the end of the line.
:earlier 10m
The :earlier command restores the buffer to its state at a specific time in the past.
:sort
The :sort command sorts lines in the current buffer or a specified range alphabetically.
ddp
The ddp sequence swaps the current line with the line below it.
:%s/\s\+$//
The :%s/\s\+$// command removes trailing whitespace (spaces and tabs) from every line in the file.