How do I make CursorHold events fire faster so plugins and diagnostics respond more quickly?
Vim's updatetime option controls two things: how quickly the swap file is written after you stop typing, and how many milliseconds of inactivity before the Curs
category:
config
tags:
#config
#performance
#autocmd
#cursorhold
#plugins
How do I run a command without moving the cursor or changing the scroll position?
:let view=winsaveview() | {cmd} | call winrestview(view)
When writing Vimscript functions or mappings, commands like :substitute, gg, or :%normal will move the cursor and change the scroll position.
category:
command-line
tags:
#ex-commands
#editing
#vimscript
#navigation
How do I open a file and jump directly to a specific line or pattern?
The :edit command accepts a +{cmd} prefix that executes an Ex command immediately after the file is loaded.
category:
command-line
tags:
#buffers
#ex-commands
#navigation
#command-line
How do I read man pages inside Neovim with syntax highlighting and tag navigation?
Neovim ships with a built-in :Man command (the man.
category:
command-line
tags:
#neovim
#navigation
#documentation
#command-line
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 reindent a block of code using a visual selection?
After making a visual selection, pressing = applies Vim's auto-indent to every selected line at once.
category:
visual-mode
tags:
#visual-mode
#indentation
#editing
#formatting
How do I make substitutions replace every match on a line by default without typing the g flag?
By default, :s/old/new/ only replaces the first occurrence of a pattern on each line.
category:
config
tags:
#config
#search
#substitute
#ex-commands
How do I open the alternate buffer in a new split while keeping my current window unchanged?
If you often compare your current file against the previously visited buffer, replacing the current window is disruptive.
category:
buffers-windows
tags:
#buffers
#windows
#splits
#navigation
How do I paste or reuse my last search pattern?
Vim stores your last search pattern in the / register.
category:
registers
tags:
#registers
#search
#insert-mode
#command-line
How do I run a command on every line that does NOT match a pattern?
:v (short for :vglobal) is the inverse of :g.
category:
command-line
tags:
#ex-commands
#command-line
#editing
How do I interactively browse and set all Vim options in a single window?
:options opens a special Vim buffer that lists every available option, grouped by category (appearance, editing, search, etc.
category:
config
tags:
#config
#ex-commands
How do I auto-indent a block of code in visual selection without specifying a line range?
Pressing = in visual mode re-indents all selected lines according to the current filetype's indent rules — the same engine used by == for a single line, but a
category:
visual-mode
tags:
#visual-mode
#indentation
#editing
#text-objects
How do I limit a search or substitution to only the text I visually selected?
The \%V atom in a Vim pattern matches only inside the last visual selection.
category:
search
tags:
#search
#visual-mode
#substitute
#regex
#text-objects
How do I paste my last Ex command into the command line or a buffer?
Vim stores your last executed Ex command in the read-only : register.
category:
registers
tags:
#registers
#ex-commands
#command-line
How do I selectively merge changes between two files in Vim's diff mode?
When comparing two files side by side with :diffsplit or vim -d, you often want to pull specific changes from one file into another rather than accepting all di
category:
buffers-windows
tags:
#buffers
#windows
#editing
#ex-commands
How do I step through a Vimscript command or function to debug it interactively?
The :debug command prefix puts Vim into its built-in interactive debugger before executing the given command.
category:
command-line
tags:
#ex-commands
#debugging
#command-line
#vimscript
How do I accept or reject individual changes in Vim's diff mode?
When reviewing differences between files in Vim's built-in diff mode, dp and do let you selectively apply individual hunks without leaving the editor.
category:
buffers-windows
tags:
#buffers
#windows
#diff
#editing
How do I capture shell command output directly into a Vim register?
You can populate any Vim register with the output of an external shell command using :let @{register} = system('{command}').
category:
registers
tags:
#registers
#ex-commands
#shell
How do I open a file in a split window and jump directly to the first match of a pattern?
The +{cmd} syntax lets you run an Ex command immediately after a file is opened.
category:
buffers-windows
tags:
#buffers-windows
#navigation
#ex-commands
How do I pipe selected text through an external command and replace it?
The ! operator in normal mode pipes text through an external shell command and replaces it with the output.
category:
command-line
tags:
#command-line
#shell
#editing
#filtering
#unix