How do I quickly switch between the current file and the last edited file?
Pressing (Ctrl-6 on most keyboards) instantly toggles between the current buffer and the alternate file — the last file you were editing.
category:
buffers-windows
tags:
#navigation
#buffers
#normal-mode
#productivity
#windows
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 run an interactive git blame inside Vim?
The vim-fugitive plugin by Tim Pope provides a powerful interactive :Git blame that goes far beyond the basic command-line git blame.
category:
plugins
tags:
#plugins
#fugitive
#git
#blame
#history
How do I edit a file on a remote server directly from Vim?
:e scp://user@host//path/to/file
Vim's built-in netrw plugin supports editing files over the network using protocols like SCP, SFTP, and HTTP.
category:
command-line
tags:
#command-line
#netrw
#remote
#file-management
How do I jump to the start of the previous method or function in code?
The [m motion jumps backward to the start of the nearest enclosing or preceding method definition.
category:
navigation
tags:
#navigation
#motions
#code
#normal-mode
How do I force a search to be case-sensitive regardless of the ignorecase setting?
Vim's ignorecase and smartcase settings change how all searches behave globally.
category:
search
tags:
#search
#normal-mode
How do I copy the current file's full path to the system clipboard?
Sometimes you need to share or use the full path of the file you're editing — for a terminal command, a config file, or a chat message.
category:
registers
tags:
#registers
#ex-commands
#editing
#clipboard
How do I run an Ex command on all lines between two pattern matches?
Vim's range addressing lets you specify a line range using search patterns instead of explicit line numbers.
category:
search
tags:
#search
#ex-commands
#editing
#command-line
How do I find which plugin or script defined a specific mapping?
The :verbose prefix on mapping commands shows not just the mapping definition but also the file and line number where it was defined.
category:
command-line
tags:
#command-line
#verbose
#debug
#mapping
How do I search and replace with confirmation for each match?
Adding the c flag to a substitute command makes Vim pause at every match and ask you whether to replace it.
category:
search
tags:
#search
#substitution
#ex-commands
#editing
How do I set Vim options on a per-file basis without changing my vimrc?
A modeline is a special comment embedded in a file that Vim reads to apply file-specific settings automatically.
category:
config
tags:
#config
#editing
#modeline
#formatting
#productivity
How do I chain multiple ex commands together on one line in Vim?
:%s/foo/bar/g | %s/baz/qux/g | w
The (bar) character in Vim's command line acts as a command separator, allowing you to chain multiple ex commands together on a single line.
category:
command-line
tags:
#ex-commands
#editing
#macros
How do I reformat a paragraph or visual selection to fit a specific line width?
The gq operator reformats text to fit within your configured textwidth.
category:
visual-mode
tags:
#visual-mode
#formatting
#editing
#text-objects
How do I quickly jump to any location with two characters?
s{char}{char} (vim-sneak)
vim-sneak provides a motion that lets you jump to any location specified by two characters.
category:
plugins
tags:
#plugins
#navigation
#motions
How do I temporarily zoom a split window to full screen and then restore the layout?
<C-w>| and <C-w>_ / <C-w>=
Vim lets you temporarily maximize a split window to full width or full height, and then restore all windows to equal sizes with =.
category:
buffers-windows
tags:
#windows
#splits
#navigation
#productivity
#layout
How do I copy lines to a different location in the file without overwriting my yank register?
The :t command (short for :copy) copies addressed lines to a destination line number, leaving the unnamed register untouched.
category:
command-line
tags:
#ex-commands
#editing
#normal-mode
#registers
How do I move between split windows using direction keys in Vim?
<C-w>h / <C-w>j / <C-w>k / <C-w>l
How it works Vim lets you navigate between split windows using followed by a direction key.
category:
buffers-windows
tags:
#windows
#navigation
#normal-mode
How do I close the current buffer in Vim?
How it works The :bdelete command (often abbreviated :bd) removes the current buffer from Vim's buffer list and closes it.
category:
buffers-windows
tags:
#buffers
#navigation
#ex-commands
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 navigate between errors and results in the quickfix list?
The quickfix list is Vim's built-in way to collect a list of positions — typically compiler errors, grep results, or linter warnings — and jump between them
category:
buffers-windows
tags:
#buffers
#ex-commands
#navigation