How do I quickly create an Ex command range spanning the next N lines using a count before the colon?
Typing a count before : in normal mode automatically fills in a line range in the command line.
category:
command-line
tags:
#command-line
#ex-commands
#ranges
#normal-mode
How do I insert a literal control character or special key into the command line?
<C-v> (command-line mode)
In command-line mode (after : or /), pressing followed by any key inserts that key literally — bypassing all key notation, mappings, and special interpretatio
category:
command-line
tags:
#command-line
#search
#editing
#insert-mode
How do I create a mapping that calls a script-local function in Vim without namespace collisions?
(Script ID) is a Vimscript token that expands to a unique, per-script prefix at runtime.
category:
config
tags:
#config
#vimscript
#mappings
#functions
#normal-mode
How do I delete all lines that do NOT match a pattern?
The :v command (short for :vglobal) is the inverse of :g — it executes a command on every line that does not match the given pattern.
category:
command-line
tags:
#editing
#ex-commands
#search
#filtering
#productivity
How do I peek at a function definition without leaving my current window?
:ptag {identifier} opens a small preview window showing the definition of the given tag, while keeping your cursor in the original window.
category:
navigation
tags:
#navigation
#tags
#windows
How do I search a project without overwriting the global quickfix list?
:lvimgrep /pattern/gj **/*.js | lopen
When you already rely on the global quickfix list for compiler errors or another search, running :vimgrep can wipe that context.
category:
search
tags:
#search
#command-line
#quickfix
#navigation
How do I use gn as a text object to delete or yank the next search match?
The gn motion is a versatile text object that selects the next occurrence of the last search pattern.
category:
editing
tags:
#editing
#search
#text-objects
#normal-mode
#motions
How do I search for a pattern in the current file and navigate results with the quickfix list?
When you need to find all occurrences of a pattern in the current file and jump between them systematically, :vimgrep with % is more powerful than basic / searc
category:
search
tags:
#search
#quickfix
#ex-commands
#navigation
How do I remove duplicate consecutive lines using a substitute command?
This substitute command detects pairs of identical adjacent lines and collapses them into one, using a back-reference to match the repeated content.
category:
search
tags:
#search
#substitute
#regex
#editing
#duplicate-lines
How do I jump directly to the top-left or bottom-right window in a complex split layout?
When managing multiple splits, t jumps to the top-left window and b jumps to the bottom-right window.
category:
buffers-windows
tags:
#windows
#navigation
#buffers
How do I force a search to be case-sensitive even when ignorecase is enabled?
Adding \C anywhere in a search pattern forces case-sensitive matching for that search, overriding the global ignorecase setting.
category:
search
tags:
#search
#normal-mode
#case
How do I run a search-and-replace across all files in my argument list and only save changed buffers?
:argdo %s/\<old\>/new/ge | update
When you need to apply the same substitution across a curated set of files, :argdo is safer than a broad project-wide command.
category:
command-line
tags:
#command-line
#ex-commands
#search
#buffers
#formatting
How do I run a replacement only over the current window's location-list matches?
:ldo s/foo/bar/ge | update\<CR>
:ldo is one of the most effective ways to perform targeted, multi-file edits without touching unrelated text.
category:
command-line
tags:
#command-line
#search
#ex-commands
#buffers
How do I programmatically remove or unmap a keybinding in Neovim Lua without knowing its original definition?
vim.
category:
config
tags:
#config
#neovim
#mappings
#lsp
#normal-mode
How do I write and edit a macro as text instead of recording it live?
Write keystrokes in buffer, then "qy$
Instead of recording a macro in real-time (where mistakes mean starting over), you can write the keystrokes as text in a buffer, edit them visually, and then ya
category:
macros
tags:
#macros
#editing
#registers
#workflow
#best-practices
How do I duplicate a visual selection of lines in Vim?
How it works The :copy command (or its abbreviation :t) duplicates lines to a specified destination.
category:
visual-mode
tags:
#visual-mode
#editing
#ex-commands
How do I change the case of text during a search and replace?
Vim's substitute command supports case conversion modifiers in the replacement string.
category:
search
tags:
#search
#substitute
#regex
#text-manipulation
How do I highlight a custom pattern in the current window without affecting the search register?
:call matchadd('ErrorMsg', 'TODO')
matchadd() lets you highlight arbitrary patterns using any highlight group — without touching the search register or search highlighting.
category:
config
tags:
#search
#config
#normal-mode
How do I quickly filter a quickfix list using Vim's built-in cfilter plugin?
:packadd cfilter | Cfilter /pattern/
Large quickfix lists are hard to work with when you only care about one subset of matches.
category:
plugins
tags:
#plugins
#command-line
#search
#buffers
How do I execute Ctrl-W window commands from the command line or a Vimscript function?
:wincmd {key} executes any {key} window command from the Ex command line or from inside a Vimscript function.
category:
buffers-windows
tags:
#windows
#ex-commands
#buffers-windows