How do I scroll the screen to position the cursor line at the center, top, or bottom?
Vim's z scroll commands reposition the screen relative to the cursor without moving the cursor itself.
category:
navigation
tags:
#navigation
#scrolling
#viewport
#cursor-position
How do I save only modified files across the argument list in Vim?
When working through an argument list, many files may remain unchanged.
category:
command-line
tags:
#command-line
#buffers
#ex-commands
#refactoring
How do I continuously record and restore sessions with vim-obsession?
If you routinely work across many files, tabs, and split layouts, rebuilding your workspace after a restart is costly.
category:
plugins
tags:
#plugins
#sessions
#workflow
#buffers-windows
#productivity
How do I run one substitution in nomagic mode so most regex characters are literal?
:snomagic /foo.\+/bar/<CR>
When a pattern is mostly literal text with just a little regex, default magic mode can force extra escaping and make substitutions harder to read.
category:
command-line
tags:
#command-line
#search
#regex
#editing
How do I turn off diff mode in all windows at once after comparing files?
The :diffoff! command exits diff mode in every window simultaneously.
category:
buffers-windows
tags:
#buffers-windows
#ex-commands
#editing
How do I hide noisy completion messages in Vim's command line?
Insert-mode completion can spam the command line with status text like "match 1 of N" and related prompts.
category:
config
tags:
#config
#completion
#command-line
#options
#insert-mode
How do I trim trailing whitespace across all files in the arglist?
:argdo %s/\s\+$//e | update
When you need to clean up many files at once, :argdo lets you run the same command on every buffer in your argument list.
category:
command-line
tags:
#command-line
#ex-commands
#formatting
#search
How do I navigate compiler errors, grep results, or search matches using the quickfix list?
The quickfix list is Vim's built-in mechanism for navigating a list of file locations — compiler errors, grep results, search matches, or any structured outpu
category:
navigation
tags:
#navigation
#quickfix
#ex-commands
#productivity
#workflow
How do I make wrapped lines preserve their indentation level?
When wrap is enabled, long lines wrap to the next screen row starting at column 1 by default, which makes indented code look messy.
category:
config
tags:
#config
#formatting
#indentation
How do I center, right-align, or left-align lines of text using Ex commands?
Vim has built-in Ex commands to align text: :center, :right, and :left.
category:
editing
tags:
#editing
#formatting
#ex-commands
#text-objects
How do I enable matchit so % jumps between if/else/end style pairs?
The default % motion is great for simple delimiters, but many code structures use semantic pairs like if/else/endif, try/catch, or HTML tags.
category:
plugins
tags:
#plugins
#navigation
#motions
#matchit
How do I tune diffopt so diffs align moved code and produce cleaner hunks?
:set diffopt+=algorithm:patience,indent-heuristic,linematch:60
Default diff settings can produce noisy hunks when code is moved, re-indented, or lightly refactored.
category:
config
tags:
#config
#diff
#review
#productivity
How do I sort selected lines numerically in visual mode using the first number on each line?
Plain :sort n is useful, but it only works when the numeric key starts at the beginning of each line.
category:
visual-mode
tags:
#visual-mode
#sorting
#ex-commands
#text-processing
How do I convert variable names between snake_case, camelCase, and other naming conventions with vim-abolish?
The vim-abolish plugin adds coercion operators that instantly convert the word under the cursor between common naming conventions.
category:
plugins
tags:
#editing
#text-objects
#plugins
#normal-mode
#formatting
How do I change the cursor shape for different Vim modes in the terminal?
Modern terminals support cursor shape changes via escape sequences.
category:
config
tags:
#config
#cursor
#terminal
#visual-feedback
How do I jump between unmatched #if, #else, and #endif preprocessor directives in Vim?
Vim provides the ]# and [# motions specifically for navigating C preprocessor conditionals.
category:
navigation
tags:
#navigation
#normal-mode
#motions
How do I quickly delete all lines in the current buffer?
The % range address in Ex commands stands for the entire file — it is shorthand for 1,$ (first line to last line).
category:
command-line
tags:
#ex-commands
#editing
#command-line
How do I quickly navigate quickfix entries, buffers, and toggle options with bracket keys?
The vim-unimpaired plugin by Tim Pope provides pairs of bracket mappings for common navigation and toggling tasks.
category:
plugins
tags:
#plugins
#navigation
#buffers
#quickfix
How do I make Vim remove the comment leader from the second line when joining two comment lines?
Adding the j flag to formatoptions causes Vim to strip the comment leader from the second line when two comment lines are joined with J.
category:
config
tags:
#editing
#formatting
#config
#ex-commands
How do I format and pretty-print JSON in the current Vim buffer using Python?
When editing JSON files in Vim, you can pipe the entire buffer through Python's built-in json.
category:
editing
tags:
#editing
#formatting
#ex-commands
#json
#shell