How do I force-convert all indentation including tabs in the middle of lines throughout an entire file?
The :retab command converts leading whitespace according to the current tabstop and expandtab settings, but it only touches indentation at the start of lines.
category:
editing
tags:
#editing
#indentation
#formatting
#ex-commands
How do I move to the end of the visible screen line when text is soft-wrapped?
The g$ command moves the cursor to the last character of the current screen line, not the end of the logical line.
category:
navigation
tags:
#navigation
#motions
#wrap
#normal-mode
How do I access and reuse the last search pattern?
The / register contains the most recent search pattern.
category:
registers
tags:
#registers
#search
How do I duplicate the current line to the end of the file without yanking or moving the cursor?
The Ex command :.
category:
editing
tags:
#editing
#ex-commands
#copy
#ranges
How do I list only modified or active buffers in Vim?
The :ls command (or :buffers) supports filter flags that narrow the buffer list to specific states.
category:
buffers-windows
tags:
#buffers
#ex-commands
#workflow
#navigation
How do I zero-pad issue numbers without changing the # prefix?
:%s/#\zs\d\+/\=printf('%04d', submatch(0))/g
For log files, changelogs, or issue references, you sometimes need fixed-width numeric IDs without touching surrounding syntax.
category:
editing
tags:
#editing
#ex-commands
#substitute
#regex
#text-processing
How do I remove trailing whitespace across all open buffers and save only changed files?
:bufdo keeppatterns %s/\s\+$//e | update
If you keep many files open during a refactor, cleaning trailing whitespace one buffer at a time is slow and error-prone.
category:
buffers-windows
tags:
#buffers
#command-line
#editing
#whitespace
How do I keep an argument list change local to the current window?
By default, Vim's argument list is global, so changing it in one window can unexpectedly affect another workflow in a different tab or split.
category:
command-line
tags:
#command-line
#arglist
#workflow
#windows
How do I save all modified buffers at once without switching to each one?
When working across multiple files, you often have unsaved changes in several buffers.
category:
command-line
tags:
#buffers
#ex-commands
#editing
How do I toggle the display of hidden dot-files in Vim's built-in netrw file browser?
When browsing files with Vim's built-in netrw file explorer (:Explore or :Ex), hidden files starting with a dot (.
category:
plugins
tags:
#navigation
#buffers-windows
#plugins
How do I paste text before the cursor while leaving the cursor positioned after the pasted content?
The gP command works like P (paste before the cursor) but leaves your cursor after the pasted text rather than at its beginning.
category:
editing
tags:
#editing
#paste
#registers
#normal-mode
How do I allow block selections past end-of-line while still permitting one-char past EOL cursor movement?
:set virtualedit=block,onemore
virtualedit controls whether the cursor can move to positions that do not yet contain text.
category:
config
tags:
#config
#visual-mode
#blockwise
#editing
#cursor
How do I paste text from outside Vim without messing up indentation?
The :set paste command enables paste mode, which temporarily disables auto-indentation, smart tabs, and other insert-mode features that can mangle text pasted f
category:
config
tags:
#config
#editing
#insert-mode
How do I quickly toggle comments on lines of code in Vim?
The vim-commentary plugin by Tim Pope provides a simple, operator-based way to comment and uncomment code.
category:
plugins
tags:
#plugins
#editing
#normal-mode
#visual-mode
How do I get exact current and total counts for my last search pattern in Vim?
:echo searchcount({'recompute': 1})
Vim can show match counts for your last search, but in large files or after big edits the cached values may lag.
category:
search
tags:
#search
#command-line
#automation
#statusline
#diagnostics
How do I set the tab width in Vim?
:set tabstop=4 shiftwidth=4 expandtab
The :set tabstop=4 shiftwidth=4 expandtab command configures Vim to use 4-space indentation with spaces instead of tab characters.
category:
config
tags:
#config
#indentation
#ex-commands
How do I use expressions in Vim's substitute replacement?
:%s/pattern/\=expression/g
Vim's substitute command supports expression replacements using \= in the replacement string.
category:
search
tags:
#search
#substitution
#ex-commands
#regex
#advanced
How do I search for multiple alternative patterns at once in Vim?
How it works The \ operator in Vim's search pattern works like a logical OR, letting you match any one of several alternatives.
category:
search
tags:
#search
#normal-mode
#ex-commands
How do I reopen the last Telescope picker with my previous search and results still there?
The :Telescope resume command reopens the most recent Telescope picker, restoring the exact query string, filtered results, and cursor position from the last ti
category:
plugins
tags:
#telescope
#search
#navigation
#plugins
#fuzzy-find
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