How do I run a macro on only the lines I've visually selected?
:'<,'>norm @q
When you visually select lines and then type a : command, Vim automatically inserts ' (the visual range marks) into the command line.
2277 results for "@a"
:'<,'>norm @q
When you visually select lines and then type a : command, Vim automatically inserts ' (the visual range marks) into the command line.
:set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20
Neovim's guicursor option lets you assign a distinct cursor shape and style to each mode, providing immediate visual feedback about which mode you are in.
daw
The daw command deletes a word including one side of its surrounding whitespace.
{count}|
The command moves the cursor to a specific screen column on the current line.
"ap, edit, "ayy
Vim stores macros in registers, which means you can paste a macro's contents into a buffer, edit it as regular text, and yank it back into the register.
<C-r>{reg} in command line
While on the : command line, pressing followed by a register name inserts that register's contents.
:echo strtrans(@q)
When a macro behaves unexpectedly, :echo strtrans(@q) reveals exactly what is stored in register q—including invisible control characters—as human-readable
Paste with "ap and execute keys manually
To debug a macro, paste its contents into the buffer, read each keystroke, and execute them one at a time to find where the macro goes wrong.
:let s:u=&l:undolevels | setlocal undolevels=-1 | execute "normal! a\<BS>\<Esc>" | let &l:undolevels=s:u
Sometimes you finish a risky refactor and want a clean undo boundary before handing the buffer off or continuing with unrelated edits.
let {var} =<< {marker}
Vim 8.
:verbose set option?
The :verbose prefix shows where an option was last set (which file, which line).
: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={
:let @q .= "keys"
The string concatenation assignment :let @q .
<C-v>jj"ay then "ap
How it works Vim registers remember not just the text content but also the type of selection that was used to yank it: characterwise, linewise, or blockwise.
@"
Vim macros are stored in registers — and you can execute any register as a macro with @{register}.
:ldo {cmd}
Vim maintains two parallel systems for collections of file positions: the quickfix list (global, one per Vim session) and the location list (local to each windo
<C-w>H / <C-w>J / <C-w>K / <C-w>L
The H, J, K, and L commands move the current window to the far left, bottom, top, or right of the screen respectively, rearranging your entire split layout.
buffers-windows #windows #buffers #navigation #splits #layout
<C-r><C-o>{reg}
When you use a in insert mode to paste register a, Vim inserts the text as if you typed it character by character.
:let @q = "dwelp"
Recording macros with q works well for simple sequences, but complex macros with special keys can be hard to get right in one take.
:g/pattern1/s/pattern2/replacement/g
Combining :g with :s lets you apply a substitution using two independent patterns: :g selects which lines to act on, and :s controls what gets replaced within t