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
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 only a visual selection using a fixed virtual column as the key?
When lines contain aligned columns, plain :sort often gives the wrong order because it compares from column 1.
category:
visual-mode
tags:
#visual-mode
#sorting
#text-processing
#command-line
How do I run an interactive replacement across quickfix entries and only save changed files?
:cdo keeppatterns s/\<foo\>/bar/gec | update
When quickfix already contains precise targets, :cdo gives you a safer multi-file replace loop than broad project substitutions.
category:
command-line
tags:
#command-line
#quickfix
#substitute
#refactoring
How do I run a literal project-wide vimgrep for the word under my cursor?
:vimgrep /\V<C-r><C-w>/gj **/*
When you need a project-wide search for the exact word under your cursor, this pattern avoids regex surprises and immediately populates quickfix.
category:
search
tags:
#search
#quickfix
#command-line
#project-workflow
How do I mix very-nomagic and magic sections in a single Vim search?
Sometimes you need one search pattern that treats a literal path strictly while still using regex power for the suffix.
category:
search
tags:
#search
#regex
#pattern
#advanced
How do I jump to the previous change and reveal it clearly in Vim?
Jumping through the changelist with g; is useful, but in real files the destination can land inside a closed fold or off-center on screen, which slows review.
category:
navigation
tags:
#navigation
#changelist
#folding
#motions
How do I put all visible windows into diff mode and balance their sizes in Vim?
:windo diffthis | wincmd =<CR>
When you already have multiple related buffers open, you can enter diff mode across all visible windows in one shot and then normalize layout width/height immed
category:
buffers-windows
tags:
#buffers
#windows
#diff
#ex-commands
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 prepend // to every line using one Vim command?
When you need to comment a whole block quickly, :global combined with :normal is faster than recording a macro or entering Visual Block mode.
category:
editing
tags:
#editing
#ex-commands
#global
#normal-mode
How do I list only search-pattern history entries in Vim?
Power users tend to run long, composable searches during refactors, but the default / and ? history navigation can be noisy when command history and search hist
category:
command-line
tags:
#command-line
#search
#history
#regex
How do I execute Ex commands stored in a register instead of replaying it as normal-mode keys?
Most macro workflows focus on @q, which replays register q as normal-mode keystrokes.
category:
macros
tags:
#macros
#command-line
#automation
#registers
How do I copy one register to another while preserving its exact register type?
:call setreg('b', getreg('a'), getregtype('a'))
Plain register copies like :let @b = @a move text, but they can lose important metadata about register type.
category:
registers
tags:
#registers
#advanced
#vimscript
#editing
How do I limit a search pattern to a specific line range without using :global?
Vim regex supports position atoms that can constrain where a match is allowed to occur.
category:
search
tags:
#search
#regex
#patterns
#navigation
How do I stop Vim sessions from changing my working directory when restored?
:set sessionoptions-=curdir
When you restore a session with :source Session.
category:
config
tags:
#config
#sessions
#working-directory
#command-line
How do I convert all hexadecimal numbers to decimal in Vim?
:%s/0x\x\+/\=str2nr(submatch(0), 16)/g
When cleaning logs, protocol dumps, or generated code, you may need to normalize 0x.
category:
editing
tags:
#editing
#ex-commands
#formatting
#search
How do I quickly filter a quickfix list using Vim's built-in cfilter plugin?
:packadd cfilter | Cfilter /pattern/
Large quickfix lists are hard to work with when you only care about one subset of matches.
category:
plugins
tags:
#plugins
#command-line
#search
#buffers
How do I force magic regex mode for one substitute command in Vim?
If you prefer very-magic regex syntax but don't want to change global settings, :smagic is a targeted solution.
category:
command-line
tags:
#command-line
#search
#ex-commands
#regex
How do I run a window-local setting command in every open window?
:windo setlocal colorcolumn=+1
When a setting is window-local, changing it once does not affect your other splits.
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
#formatting
How do I make Vim match only part of a larger regex using \zs and \ze?
When you need to target only a slice of a larger pattern, \zs and \ze are usually cleaner than building lookarounds.
category:
search
tags:
#search
#regex
#patterns
#ex-commands