How do I add a visual indicator at the start of soft-wrapped continuation lines?
When wrap is enabled, Vim wraps long lines at the screen edge, but there is no built-in visual marker to distinguish a wrapped continuation from a brand-new lin
category:
config
tags:
#config
#editing
#formatting
How do I show only buffers matching a pattern in Vim's :ls output?
When you have many open buffers, plain :ls output gets noisy fast.
category:
buffers-windows
tags:
#buffers
#command-line
#regex
#workflow
How do I duplicate every non-blank line in a buffer with one Ex command?
The :global command can apply an Ex action to every line that matches a pattern.
category:
editing
tags:
#editing
#ex-commands
#normal-mode
#search
How do I read or modify the lines of a buffer that is not currently displayed without switching to it?
getbufline() / setbufline()
The getbufline() and setbufline() functions let you inspect and update any loaded buffer's contents from Vimscript without switching the active window.
category:
buffers-windows
tags:
#buffers-windows
#ex-commands
How do I insert a literal control character or special key in insert mode?
When you need to insert a literal tab character despite expandtab being set, or embed a control character like ^M (carriage return) into your text, in insert mo
category:
editing
tags:
#editing
#insert-mode
#special-characters
#control-characters
How do I match a pattern only if it is NOT followed by something?
The \@! atom is a negative lookahead in Vim regex.
category:
search
tags:
#search
#normal-mode
How do I break a line at the cursor position without entering Insert mode?
You can split a line at the cursor without entering Insert mode by using r.
category:
editing
tags:
#editing
#normal-mode
#formatting
How do I append keystrokes to a macro without re-recording it?
Re-recording a long macro just to add one extra keystroke is wasteful and error-prone.
category:
macros
tags:
#macros
#registers
#automation
#editing
How do I prevent Vim from treating leading-zero numbers as octal when incrementing with Ctrl-A?
By default, Vim treats numbers prefixed with a leading zero (like 007) as octal when you use or to increment or decrement them.
category:
config
tags:
#config
#editing
#normal-mode
How do I open a file in read-only mode so I cannot accidentally modify it?
:view opens a file with the readonly option set, preventing accidental writes.
category:
buffers-windows
tags:
#buffers
#ex-commands
#editing
How do I make Ctrl-A and Ctrl-X increment and decrement hexadecimal numbers?
By adding hex to the nrformats option, you tell Vim to recognise hexadecimal literals such as 0xFF or 0xDEAD when or is pressed.
category:
config
tags:
#config
#numbers
#increment
#normal-mode
#editing
How do I use capture groups in a Vim search and replace?
Capture groups in Vim substitute let you match parts of a pattern and reuse them in the replacement.
category:
search
tags:
#search
#editing
#ex-commands
How do I open a scratch split that is not listed and disappears when I close it?
:vnew | setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
For quick throwaway notes, command output cleanup, or temporary edits, a normal buffer is noisy: it appears in :ls, can prompt you to save, and may leave swap a
category:
buffers-windows
tags:
#buffers-windows
#buffers
#windows
#scratch
#workflow
How do I sort lines based on a specific field or column rather than the beginning of each line?
The :sort /pattern/ command sorts lines by the text that appears after the first match of a pattern, not from the start of each line.
category:
command-line
tags:
#ex-commands
#editing
#visual-mode
How do I reverse the order of all lines in a file?
The :g/^/m0 command is a clever use of Vim's global command to reverse every line in the file.
category:
command-line
tags:
#editing
#ex-commands
#global-command
#lines
How do I make jumps reuse open windows first and fall back to a new tab when needed?
:set switchbuf=useopen,usetab,newtab
When jump commands open files (:tag, quickfix navigation, location list jumps), Vim may split your layout in ways that break flow.
category:
buffers-windows
tags:
#buffers
#windows
#tabs
#quickfix
#config
How do I increment or add to all numbers in a file using Vim substitution?
:%s/\d\+/\=submatch(0)+1/g
Vim's expression replacement (\=) in substitutions lets you perform arithmetic on matched text.
category:
search
tags:
#search
#substitute
#arithmetic
#numbers
How do I open the file under the cursor and jump to a specific line?
The gF command opens the file under the cursor and jumps to the line number that appears after the filename.
category:
navigation
tags:
#navigation
#buffers
#normal-mode
How do I join a specific number of lines at once without pressing J multiple times?
The J command joins the current line with the line below, adding a space between them.
category:
editing
tags:
#editing
#normal-mode
#join
#motions
How do I save and automatically restore a buffer's fold state and cursor position across Vim sessions?
:mkview saves a snapshot of the current window — its fold states, cursor position, and local option values — to a view file on disk.
category:
buffers-windows
tags:
#folding
#buffers-windows
#config
#ex-commands