How do you record a macro to remove trailing whitespace from lines?
qa:s/\s\+$//e\n jq
Record a macro that runs a substitution on the current line to remove trailing spaces, then moves down.
181 results for "n N"
qa:s/\s\+$//e\n jq
Record a macro that runs a substitution on the current line to remove trailing spaces, then moves down.
<C-x><C-l>
The command triggers whole-line completion in insert mode.
qa0f dwi\n<Esc>jq
Extract columns by recording a macro that navigates to the desired field and deletes or yanks it.
qaA <C-r>=strftime('%Y-%m-%d')\n<Esc>jq
Record a macro that appends a date stamp using the expression register with strftime().
qa/true\|false\ncgn<C-r>=@"=='true'?'false':'true'\n<Esc>q
Record a macro using cgn with an expression register to toggle between true and false.
qa*Ncgn<C-r>=newName\n<Esc>q
Record a macro using * to search for the word under cursor, cgn to change the next match, type the new name.
qa80|i\n<Esc>jq
Record a macro that moves to column 80 using 80 , inserts a newline, and moves to the next line.
/<C-r>0
How it works After yanking text, you can use it directly as a search pattern by inserting the yank register contents into the search prompt.
:tabnew / gt / gT
Vim's tab pages let you organize your workspace into separate views, each containing its own window layout.
buffers-windows #buffers #windows #tabs #navigation #productivity
:let i=1\nqao<C-r>=i\n<Esc>:let i+=1\nq
Use a counter variable with the expression register inside a macro.
:echo @/
The / register holds the most recent search pattern.
g*
The g command searches forward for the text under the cursor without adding word boundary anchors.
search #search #navigation #normal-mode #motions #productivity
crs
The vim-abolish plugin by Tim Pope provides instant case coercion commands that convert the word under your cursor between common naming conventions.
:nohlsearch
After a search in Vim, matched text is highlighted as long as hlsearch is enabled.
:pop or <C-t>
When you jump to a tag definition with , Vim pushes your location onto a tag stack.
.
The .
g* and g#
The and # commands search for the exact whole word under the cursor (with word boundaries \).
:%sort u
The :sort u command sorts all lines in the file and removes duplicate lines in one operation.
command-line #command-line #ex-commands #editing #text-manipulation #sort
:let @+ = @"
Vim's :let @{reg} syntax lets you read from one register and write to another.
:noh
The :noh (short for :nohlsearch) command clears the highlighting from the last search pattern.