How do I make Vim diff ignore whitespace and use patience algorithm for clearer hunks?
:set diffopt+=iwhite,algorithm:patience
When whitespace-only churn and noisy line matching make diffs hard to review, tuning diffopt can dramatically improve signal.
category:
config
tags:
#config
#diff
#review
#whitespace
How do I apply different macros to alternate lines?
You can create macros that call other macros, applying different operations to alternate lines or creating complex editing patterns.
category:
macros
tags:
#macros
#normal-mode
How do I reopen Vim and jump directly to where I was editing last time?
Pressing '0 in normal mode jumps to the exact cursor position in the most recently edited file, even after closing and reopening Vim.
category:
navigation
tags:
#navigation
#marks
#viminfo
#shada
#sessions
How do I set an environment variable inside Vim so it is available to shell commands I run?
Vim lets you read and write environment variables using the $VARIABLE syntax in Vimscript.
category:
config
tags:
#ex-commands
#config
#command-line
How do I run vimgrep across files using my last search pattern without retyping it?
Using // (an empty pattern) in :vimgrep tells Vim to reuse the last search pattern.
category:
search
tags:
#search
#ex-commands
#quickfix
How do I make the gq operator format code with an external tool like prettier or black?
When formatprg is set, the gq operator pipes the selected text through that external program and replaces it with the program's output.
category:
editing
tags:
#editing
#formatting
#ex-commands
#config
How do I add custom tab completion to my own Ex commands?
:command -complete=file -nargs=1 E edit <args>
When defining custom commands with :command, the -complete option adds tab completion for arguments.
category:
command-line
tags:
#command-line
#completion
#custom-command
#tab-complete
How do I cycle through my jump history in Vim?
Vim maintains a jump list of positions you have visited.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I create text abbreviations that auto-expand while typing in Vim?
:iabbrev {abbr} {expansion}
How it works The :iabbrev command creates abbreviations that automatically expand when you type them in insert mode.
category:
editing
tags:
#editing
#insert-mode
#ex-commands
How do I auto-complete words in insert mode without any plugins?
Vim has a powerful built-in completion system that requires zero plugins.
category:
editing
tags:
#editing
#insert-mode
#completion
#productivity
How do I switch between visual mode and select mode in Vim?
Vim has a lesser-known select mode that behaves like selection in typical GUI editors: any typed character replaces the selection.
category:
visual-mode
tags:
#visual-mode
#select-mode
#editing
#normal-mode
How do I fuzzy-search and run any available Vim command using fzf.vim?
fzf.
category:
plugins
tags:
#plugins
#fzf
#command-line
#fuzzy-search
How do I collect multiple project searches into one location list instead of replacing results?
:lvimgrepadd /pattern/gj **/*
When investigating a bug or refactor, you often need to gather results from several related patterns before deciding what to edit.
category:
search
tags:
#search
#location-list
#quickfix
#ex-commands
How do I run commands automatically when certain events occur?
:autocmd Event pattern command
Autocommands let you execute commands automatically in response to events like opening a file, saving, or changing buffers.
category:
command-line
tags:
#command-line
#config
#ex-commands
How do I switch between charwise, linewise, and blockwise visual mode without losing my selection?
Once you are in any visual mode, pressing v, V, or switches to charwise, linewise, or blockwise visual mode respectively — without cancelling the current sele
category:
visual-mode
tags:
#visual-mode
#normal-mode
#editing
How do I list all buffers including unlisted ones like help pages and terminal buffers?
:ls (or :buffers) shows Vim's buffer list, but it hides unlisted buffers — help files, directory listings (netrw), terminal buffers, and scratch buffers marke
category:
buffers-windows
tags:
#buffers-windows
#ex-commands
How do I return to normal mode from absolutely any mode in Vim?
While works to leave insert or visual mode, it does not work in every situation — particularly in terminal mode (:terminal), where is consumed by the running
category:
navigation
tags:
#normal-mode
#insert-mode
#visual-mode
How do I configure Vim's command-line tab completion to show all matches and complete to the longest common prefix?
:set wildmode=list:longest
Vim's wildmode option controls how the command line behaves when you press to complete filenames, buffer names, or Ex commands.
category:
config
tags:
#config
#command-line
#completion
#ex-commands
How do I move selected lines up or down in visual mode?
:'<,'>move'>+1 or :'<,'>move'<-2
How it works Vim's :move command lets you relocate lines to a different position.
category:
visual-mode
tags:
#visual-mode
#editing
#ex-commands
How do I make Tab and Enter behave differently when the completion popup menu is open?
The pumvisible() function returns 1 when the insert-mode completion popup menu (pum) is visible, and 0 otherwise.
category:
config
tags:
#config
#insert-mode
#completion