How do I prevent a count prefix or visual range from corrupting an Ex command in a Vim mapping?
When writing nnoremap or vnoremap mappings that call Ex commands, Vim may silently prepend a count or a visual range (') to your command before it runs.
category:
config
tags:
#config
#ex-commands
#normal-mode
#visual-mode
How do I keep a split at a fixed width when opening and closing other windows?
When you use a sidebar-style split for file trees, docs, or logs, automatic window equalization can constantly resize it.
category:
buffers-windows
tags:
#buffers
#windows
#layout
#workflow
How do I reflow or hard-wrap a paragraph to a set text width in Vim?
The vipgq sequence reflowing a paragraph to fit within the width defined by textwidth (default 0, meaning no limit).
category:
visual-mode
tags:
#visual-mode
#editing
#formatting
#text-objects
How do I highlight a custom pattern persistently in a window without changing the search register?
The matchadd() function adds a persistent highlight for a pattern in the current window without touching your search register or interfering with n/N navigation
category:
search
tags:
#search
#config
#visual-mode
#normal-mode
How do I edit a complex Ex command in a full editing window?
q: or <C-f> from : prompt
The command-line window (q:) opens a full Vim buffer containing your Ex command history.
category:
command-line
tags:
#command-line
#history
#editing
#workflow
How do I open a file for reference in a dedicated preview window without disturbing my split layout?
Vim has a built-in preview window — a special window distinct from regular splits.
category:
buffers-windows
tags:
#buffers
#windows
#navigation
#ex-commands
How do I write a Vim macro that automatically repeats until it fails?
A recursive macro is one that calls itself as its final action, causing it to repeat indefinitely until any command in the body fails (e.
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I change whether a register pastes as character, line, or block-wise?
:call setreg('"', @", 'l')
Vim registers carry not just their text content but also a type: charwise (c), linewise (l), or blockwise (b).
category:
registers
tags:
#registers
#editing
#normal-mode
#paste
How do I re-insert the text I typed in the previous insert session?
While in insert mode, pressing re-inserts the exact text you typed during your previous insert session.
category:
editing
tags:
#insert-mode
#editing
#registers
How do I run a normal mode command on every line matching a pattern?
The :g/pattern/normal {commands} command executes normal mode keystrokes on every line in the file that matches the given pattern.
category:
command-line
tags:
#ex-commands
#command-line
#editing
#search
How do I run a shell command on a range of lines in normal mode and replace them with the output?
In normal mode, !{motion} sends the lines covered by the motion to a shell command's stdin and replaces them with stdout.
category:
editing
tags:
#editing
#ex-commands
#normal-mode
#formatting
How do I use a count with a text object to operate on multiple words, sentences, or paragraphs at once?
Most Vim users know you can put a count before an operator (3dw) or use a text object once (daw).
category:
editing
tags:
#text-objects
#editing
#delete
#normal-mode
#motions
How do I use the filename under the cursor as a value in a Vim mapping or command?
The expand('') function returns the filename that Vim sees under the cursor — the same file that gf would open.
category:
command-line
tags:
#command-line
#ex-commands
#navigation
#editing
#motions
How do I right-align a block of text to a specific column width using an Ex command?
Vim has built-in Ex commands for text alignment — :right, :left, and :center — that work over any line range without plugins.
category:
command-line
tags:
#formatting
#indentation
#command-line
#ex-commands
How do I change each occurrence of a search match one at a time, confirming each with the dot command?
The cgn + .
category:
search
tags:
#search
#editing
#normal-mode
#motions
How do I use glob() in Vimscript to get a list of files matching a wildcard pattern?
The glob() built-in function expands a wildcard pattern into a list of matching filesystem paths, entirely within Vimscript.
category:
config
tags:
#config
#vimscript
#files
#ex-commands
How do I paste back a small deletion (like a deleted character) while in insert mode?
In insert mode, - pastes the contents of the small delete register ("-).
category:
registers
tags:
#registers
#insert-mode
#editing
How do I save my last Ex command into a register so I can replay it as a macro?
The : register always holds the last Ex command you ran.
category:
macros
tags:
#macros
#registers
#ex-commands
#workflow
How do I jump to a specific byte offset position in a file?
The go command moves the cursor to a specific byte offset from the start of the buffer.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I jump to the exact column position of a mark?
The backtick command ` ` followed by a mark name jumps to the exact line and column of that mark, unlike the single-quote ' which only goes to the line.
category:
navigation
tags:
#navigation
#marks
#normal-mode