How do I strip trailing whitespace without clobbering my last search pattern?
:keeppatterns %s/\s\+$//e
Bulk cleanup commands often damage your navigation flow by overwriting the last search pattern (@/).
category:
command-line
tags:
#command-line
#search
#substitution
#whitespace
How do I fold and unfold sections of code to hide details I'm not working on?
Vim's folding system lets you collapse blocks of code into a single line, hiding the details so you can focus on the structure.
category:
editing
tags:
#editing
#folding
#navigation
#normal-mode
#productivity
How do I move forward or backward by sentence in Vim?
The ) and ( motions move by sentence boundaries.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I regenerate help tags for every installed plugin in one command?
Plugin help can break after manual installs, local plugin development, or branch switches that add/remove docs.
category:
plugins
tags:
#plugins
#help
#documentation
#runtimepath
How do I jump to the next section or function definition in Vim?
The ]] motion jumps forward to the next line that starts with { in the first column, which is typically the beginning of a C-style function or section.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I indent the current line without changing local marks in Vim?
When you run editing commands from the command line, Vim usually updates special marks like '[ and '] to the changed text.
category:
editing
tags:
#editing
#ex-commands
#marks
#normal-mode
How do I run a Normal-mode command through :execute in Vim?
:execute "normal! gg=G"<CR>
:execute lets you build and run Ex commands dynamically, which is critical when a command depends on variables, conditionals, or string composition.
category:
command-line
tags:
#command-line
#ex-commands
#normal-mode
#automation
How do I uppercase text inside an HTML tag without changing the tags?
When editing markup-heavy files, you often need to transform only the tag contents while preserving the surrounding structure.
category:
visual-mode
tags:
#visual-mode
#text-objects
#editing
#html
How do I append a semicolon to every non-blank line with one Vim command?
:g/[^[:space:]]/normal! A;\<CR>
When you need to patch many lines at once, :g with :normal! is often faster and safer than recording a macro.
category:
command-line
tags:
#command-line
#ex-commands
#editing
#normal-mode
How do I add Emacs-style editing shortcuts to Vim's command line?
Vim's command line has limited navigation by default.
category:
command-line
tags:
#command-line
#mapping
#cnoremap
#editing
How do I uppercase only the current search match using gn as a motion?
gn is often treated as a visual selection command, but it is more powerful when used as a motion target for operators.
category:
search
tags:
#search
#motions
#editing
#normal-mode
How do I preview quickfix entries without leaving the quickfix window?
The preview window shows file contents temporarily without switching your editing context.
category:
buffers-windows
tags:
#buffers-windows
#quickfix
#preview
#navigation
How do I record a macro that uppercases a word and advances so I can replay it across words?
Macros are most powerful when they encode both the edit and the movement to the next target.
category:
macros
tags:
#macros
#editing
#motions
#normal-mode
How do I open another buffer in a split without changing the alternate-file register?
The alternate-file register (#) is easy to disturb when jumping around buffers, and many advanced motions depend on it (, # expansions, quick two-file toggles).
category:
buffers-windows
tags:
#buffers
#windows
#command-line
#navigation
How do I replace the next word with a yanked word without clobbering the unnamed register?
When you are doing repetitive refactors, cw is fast but it overwrites the unnamed register with the replaced text.
category:
registers
tags:
#registers
#editing
#normal-mode
#insert-mode
How do I uppercase a word and then jump back to my exact original cursor position?
When you run an operator like gUiw, Vim can leave your cursor in a slightly different place than where you started.
category:
editing
tags:
#editing
#marks
#motions
#normal-mode
How do I move by display lines when long lines wrap?
The gj command moves the cursor down by one display line rather than one physical line.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I jump between function or section boundaries in Vim?
[[ and ]] navigate between section boundaries — typically the start of the previous or next top-level block.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I record one edit and replay it on the next two lines with a macro?
Macros are strongest when the edit pattern is stable but too awkward for a one-liner substitute.
category:
macros
tags:
#macros
#editing
#normal-mode
#automation
How do I launch GDB inside Vim using the built-in termdebug plugin without preloading it?
:packadd termdebug | Termdebug ./a.out
If you only debug occasionally, loading termdebug on demand keeps startup lean while still giving you an in-editor GDB workflow.
category:
plugins
tags:
#plugins
#debugging
#command-line
#workflow