How do I find out which script or plugin defined a specific mapping or setting?
:verbose map <key> or :verbose set option?
The :verbose prefix shows where a mapping, setting, command, or function was defined — which file and line number.
category:
command-line
tags:
#command-line
#debugging
#config
#mappings
#workflow
How do I show context lines around each match when using the :global command?
The :global command is great for finding lines matching a pattern, but by default it only shows the matching lines themselves.
category:
command-line
tags:
#search
#ex-commands
#navigation
#command-line
How do I reformat a paragraph to fit a specific line width?
The gqip command reformats the current paragraph to fit within the configured textwidth.
category:
editing
tags:
#editing
#formatting
#text-objects
#normal-mode
How do I move the cursor to the other end of a visual selection without restarting it?
In visual mode, pressing o swaps the cursor between the two ends of the selection (the anchor and the free end).
category:
visual-mode
tags:
#visual-mode
#navigation
#editing
How do I open the current file on GitHub directly from Vim?
The vim-fugitive plugin combined with vim-rhubarb (for GitHub support) provides the :GBrowse command, which opens the current file on your repository's web host
category:
plugins
tags:
#plugins
#fugitive
#git
#github
#workflow
How do I quickly replace a word and then repeat it elsewhere?
ciw + new text + Esc, then n.
The ciw command followed by new text, combined with and .
category:
editing
tags:
#editing
#search
#normal-mode
How do I record a macro to wrap each word in quotes?
This macro wraps the current word in double quotes by changing the word, inserting quotes around the original content, and moving to the next word.
category:
macros
tags:
#macros
#editing
#registers
How do I view a side-by-side Git diff of staged changes inside Vim?
The vim-fugitive plugin provides :Gdiffsplit (and its vertical variant :Gvdiffsplit) to open a side-by-side diff view comparing the working tree version of a fi
category:
plugins
tags:
#plugins
#fugitive
#git
#diff
#staging
How do I align text around a delimiter character using vim-lion?
vim-lion (by Tom McDonald) adds gl and gL as alignment operators.
category:
plugins
tags:
#plugins
#editing
#formatting
How do I uppercase or lowercase matched text directly in a substitute command?
Vim's substitute replacement string supports special case-transform atoms that change the case of matched text without requiring a second pass or an external to
category:
editing
tags:
#editing
#search
#ex-commands
#formatting
How do I run an Ex command without changing the current search pattern?
Many Ex commands silently overwrite the search register (@/), which changes your hlsearch highlighting and n/N behavior.
category:
command-line
tags:
#ex-commands
#search
#command-line
How do I fix a misspelled word using Vim's spell checker while staying in insert mode?
When spell checking is enabled (:set spell), s in insert mode opens a popup menu of suggested corrections for the most recently flagged misspelled word — with
category:
editing
tags:
#editing
#insert-mode
#completion
#search
How do I jump between sentences in Vim?
How it works Vim defines a sentence as text ending with .
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I jump to a specific percentage position in a file?
The {N}% command jumps the cursor to the line that is N percent of the way through the file.
category:
navigation
tags:
#navigation
#motions
#normal-mode
#productivity
How do I do a case-preserving search and replace in Vim?
:%s/\v(old)/\=toupper(submatch(0)[0]).tolower(submatch(0)[1:])/g
Standard substitutions don't preserve the original case of matched text.
category:
search
tags:
#search
#substitute
#case
#text-transformation
How do I filter a visual selection through an external shell command?
Vim can pipe a visual selection through any shell command and replace the selection with the command's output.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#external-commands
#filtering
How do I write autocommands that don't duplicate when I reload my vimrc?
augroup name | autocmd! | autocmd ... | augroup END
Autocommand groups (augroup) with autocmd! prevent duplicate autocommands from accumulating every time you source your vimrc.
category:
config
tags:
#config
#autocommands
#vimrc
#best-practices
How do I put selected text inside quotes or brackets manually?
Without a surround plugin, you can manually wrap selected text by changing it, typing the delimiters, and pasting the original text back.
category:
visual-mode
tags:
#visual-mode
#editing
How do I jump to the beginning of the previous word?
The b command moves the cursor backward to the beginning of the previous word.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I browse the full commit history of the current file using vim-fugitive?
vim-fugitive's :G log -- % loads the git commit history for the current file into a quickfix-style log buffer.
category:
plugins
tags:
#plugins
#buffers
#navigation
#ex-commands