How do I edit a macro without re-recording it?
:let @q = substitute(@q, 'old', 'new', '')
Vim macros are stored as plain text in named registers, which means you can inspect and modify them directly using :let and :echo.
2125 results for "i( a("
:let @q = substitute(@q, 'old', 'new', '')
Vim macros are stored as plain text in named registers, which means you can inspect and modify them directly using :let and :echo.
:%s/^/\=line('.').' '/
Vim's substitute command supports expressions in the replacement string using \=.
:e scp://user@host//path/to/file
Vim's built-in netrw plugin supports editing files over the network using protocols like SCP, SFTP, and HTTP.
:'<,'>center
After making a visual selection, typing : automatically inserts ' to scope the command to the selection.
visual-mode #visual-mode #formatting #ex-commands #indentation
qa:s/old/new/g<CR>jq
How it works You can combine Ex commands like :s (substitute) with macro recording to create powerful repeatable find-and-replace operations that go beyond what
:%normal @q
To apply a macro to every line in the file, use :%normal @q.
!{motion}{cmd}<CR>
In normal mode, !{motion} sends the lines covered by the motion to a shell command's stdin and replaces them with stdout.
d3aw
Most Vim users know you can put a count before an operator (3dw) or use a text object once (daw).
editing #text-objects #editing #delete #normal-mode #motions
expand('<cfile>')
The expand('') function returns the filename that Vim sees under the cursor — the same file that gf would open.
command-line #command-line #ex-commands #navigation #editing #motions
:let g:netrw_liststyle = 3
By default, netrw shows files in a flat listing.
plugins #netrw #file-browser #plugins #configuration #built-in
:earlier 1f
The :earlier {count}f command navigates Vim's undo tree to the state of the buffer at the time of the last (or Nth) file write.
:tabmove {n}
:tabmove {n} repositions the current tab page to index n in the tab bar (0-indexed from the left).
:cq
The :cq command quits Vim and returns a non-zero exit code to the calling process.
:e ++enc=utf-8
When Vim opens a file with the wrong encoding — producing garbled text or incorrect characters — you can reload it with a specific encoding using :e ++enc={
:sort r /\w\+$/
The :sort r /{pattern}/ command sorts lines using the text that matches the pattern as the sort key.
:args **/*.py
Vim's argument list (arglist) is a named list of files that you can operate on as a group.
:debug normal @q
Recorded macros are powerful, but when one keystroke goes wrong they can fail fast and leave confusing state behind.
gUiw
The gUiw command converts the entire word under the cursor to uppercase.
{count}@{register}
Prefix any macro execution with a count to repeat it that many times in a single command.
:%!command
:%!{command} replaces the entire buffer contents with the output of piping them through a shell command.