How do I run a literal project-wide vimgrep for the word under my cursor?
:vimgrep /\V<C-r><C-w>/gj **/*
When you need a project-wide search for the exact word under your cursor, this pattern avoids regex surprises and immediately populates quickfix.
category:
search
tags:
#search
#quickfix
#command-line
#project-workflow
How do I view the first macro or keyword definition without leaving my current position?
The [d command searches from the beginning of the file for the first line matching the define pattern for the word under the cursor, and displays it in the stat
category:
search
tags:
#search
#navigation
#normal-mode
How do I sort lines using only the text under a visual column?
When you need to sort records by a substring that starts at a visual column, Vim can do it without external tools.
category:
visual-mode
tags:
#visual-mode
#sorting
#ex-commands
#text-processing
How do I control what state gets saved when I use :mkview to snapshot a window?
:set viewoptions=cursor,folds,slash,unix
The viewoptions setting is a comma-separated list that determines exactly what :mkview (and the auto-save view pattern) stores in a view file.
category:
config
tags:
#config
#folding
#views
#options
#ex-commands
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 navigate quickfix entries, buffers, and conflicts with consistent bracket mappings?
The vim-unimpaired plugin (by Tim Pope) provides a consistent [x / ]x mnemonic for navigating any list-like structure in Vim.
category:
plugins
tags:
#navigation
#buffers
#macros
#ex-commands
How do I make Vim's search stop at the end of the file instead of wrapping back to the top?
By default Vim's wrapscan option is enabled, which causes / and ? searches to wrap silently from the end of the file back to the beginning (and vice versa).
category:
config
tags:
#search
#config
#options
How do I toggle a boolean Vim option on and off without typing the full :set option or :set nooption each time?
For any boolean option, appending ! to :set inverts its current value.
category:
config
tags:
#config
#options
#vimrc
#editing
How do I jump to a tag and get an interactive list when multiple definitions exist in Vim?
:tjump {identifier} is the smart tag-jumping command: it jumps directly when there is only one matching tag, but shows an interactive numbered list when multipl
category:
navigation
tags:
#navigation
#tags
#buffers-windows
How do I search for yanked text literally in Vim without escaping regex characters?
When your yanked text includes regex symbols like .
category:
search
tags:
#search
#registers
#command-line
#regex
How do I programmatically combine or modify the contents of Vim registers?
You can manipulate register contents directly using the :let command with the @{reg} syntax.
category:
registers
tags:
#registers
#editing
#normal-mode
#ex-commands
How do I run a substitution only within the exact characters of my visual selection?
:%s/\%Vpattern/replacement/g
The \%V atom restricts a regex match to the last visual selection — more precisely than :'s/.
category:
search
tags:
#search
#visual-mode
#ex-commands
#normal-mode
How do I search and replace only within a visual block selection?
The \%V atom restricts a search pattern to match only within the visual selection area, including visual block selections.
category:
search
tags:
#search
#substitute
#visual-mode
#block-mode
#regex
How do I manually re-trigger filetype-based autocmds without reopening the file?
When you change a buffer's filetype mid-session — say with :set filetype=python — Vim updates the filetype option but does not automatically re-run the File
category:
command-line
tags:
#ex-commands
#autocmd
#filetype
#config
How do I use case modifiers like \u and \U in a substitution replacement to change capitalization?
Vim's substitute command supports case-modifier escapes in the replacement string: \u uppercases the next character, \U uppercases all text until \E or end of r
category:
search
tags:
#search
#editing
#substitute
#regex
#ex-commands
How do I sort selected lines in Vim?
The :'sort command sorts the currently selected lines in visual mode alphabetically.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#editing
#formatting
How do I instantly erase everything I have typed on the command line and start the command over?
When you are typing a long Ex command on the : prompt and realise you've made a mistake, pressing erases everything from the cursor back to the beginning of the
category:
command-line
tags:
#command-line
#ex-commands
#editing
#insert-mode
How do I define autocmds safely so they don't duplicate when my vimrc is re-sourced?
Wrapping autocmds in a named augroup with autocmd! at the start prevents duplicate autocommands from accumulating every time your vimrc is sourced.
category:
config
tags:
#config
#ex-commands
#editing
How do I prompt the user for input in the middle of a mapping or Vimscript function?
The built-in input() function pauses execution, displays a prompt at the bottom of the screen, and returns whatever the user types before pressing Enter.
category:
macros
tags:
#macros
#editing
#ex-commands
#insert-mode
How do I make a macro conditionally execute commands based on line content?
:if condition | execute 'normal cmd' | endif
How it works Vim macros can include Ex commands with conditional logic.
category:
macros
tags:
#macros
#ex-commands
#editing