How do I persistently highlight a pattern in Vim using a specific highlight group without a plugin?
:match, :2match, and :3match give you three independent highlight slots that overlay patterns on the buffer using any highlight group — without touching the s
category:
search
tags:
#search
#config
#normal-mode
#ex-commands
How do I move all lines matching a pattern to the end of the file in Vim?
The :g (global) command combined with :m (move) lets you collect all lines matching a pattern and relocate them to a specific position in the file.
category:
command-line
tags:
#ex-commands
#editing
#global
#search
#formatting
How do I keep folds and viewport context when navigating jumps in Neovim?
:set jumpoptions=stack,view
By default, jump navigation can feel lossy in long files: you jump back, but folds, topline, and viewport context do not always match what you were looking at b
category:
config
tags:
#config
#navigation
#jumps
#workflow
How do I define or modify a macro without recording keystrokes?
Instead of recording a macro with q, you can assign any string directly to a named register using :let @{register} = 'keys'.
category:
macros
tags:
#macros
#registers
#ex-commands
#normal-mode
How do I add more steps to an existing macro without re-recording it from scratch?
When you record a macro into register q with qq.
category:
macros
tags:
#macros
#registers
#recording
#editing
How do I make the focused window automatically expand to a minimum size while keeping other windows visible?
:set winwidth=85 winheight=20
Setting winwidth and winheight tells Vim the minimum column width and line height the current focused window must have.
category:
buffers-windows
tags:
#windows
#buffers
#config
#navigation
How do I create a dynamic abbreviation that inserts live content like the current date?
:iabbrev <expr> {trigger} {expression}
The flag on :iabbrev turns the right-hand side into a Vimscript expression that is evaluated at expansion time rather than stored as a literal string.
category:
config
tags:
#config
#insert-mode
#abbreviations
#ex-commands
How do I edit a file without overwriting the alternate buffer?
Every time you open a file with :edit, Vim updates the alternate file register (#) to the previous buffer.
category:
buffers-windows
tags:
#buffers
#ex-commands
#registers
#navigation
How do I cycle through previously deleted text using numbered registers?
"1p then u then . to cycle
Vim stores your last 9 deletions in numbered registers "1 through "9.
category:
registers
tags:
#registers
#editing
#undo-redo
#delete
#paste
How do I jump back to where I last inserted text and continue typing?
The gi command moves the cursor to the position where you last exited insert mode and immediately enters insert mode again.
category:
navigation
tags:
#navigation
#insert-mode
#marks
#normal-mode
#productivity
How do I visually select the text of a sentence without selecting surrounding whitespace?
The is (inner sentence) text object selects the sentence the cursor is in — excluding any leading or trailing whitespace that separates sentences.
category:
visual-mode
tags:
#visual-mode
#text-objects
#editing
How do I append text to a named register programmatically without re-recording a macro?
Vim registers are just strings, and you can read and write them directly using the :let command.
category:
registers
tags:
#registers
#vimscript
#macros
#editing
How do I move to the first non-blank character of a line?
The ^ command moves the cursor to the first non-blank character of the current line.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I reuse the last visual selection range in an Ex command after exiting visual mode in Vim?
Vim automatically sets two special marks whenever you make a visual selection: ' (end).
category:
visual-mode
tags:
#visual-mode
#marks
#ex-commands
#navigation
How do I move the cursor to the horizontal midpoint of the current screen view?
The gm command moves the cursor horizontally to the middle of the current screen width on the current line.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I join wrapped paragraph lines while keeping blank-line paragraph separators?
When text is hard-wrapped (for example from email, logs, or copied docs), joining entire paragraphs manually is slow and error-prone.
category:
editing
tags:
#editing
#formatting
#ex-commands
#text-manipulation
How do I change the working directory for only the current window without affecting other windows or tabs?
:cd changes the global working directory, affecting every window and tab in the session.
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
#navigation
How do I indent or dedent the current line without leaving insert mode?
When you're typing in insert mode and realize the current line needs more or less indentation, you don't have to leave insert mode to fix it.
category:
editing
tags:
#insert-mode
#indentation
#editing
#formatting
How do I manually set the visual selection marks to define a precise Ex command range without entering visual mode?
Vim's ' marks record the start and end of the last visual selection and power the ' range used by Ex commands.
category:
navigation
tags:
#marks
#navigation
#visual-mode
#ex-commands
How do I highlight a custom pattern persistently in a window without changing the search register?
The matchadd() function adds a persistent highlight for a pattern in the current window without touching your search register or interfering with n/N navigation
category:
search
tags:
#search
#config
#visual-mode
#normal-mode