How do I keep an argument list change local to the current window?
:arglocal
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.
:arglocal
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.
:'[,']normal! =
When you need to run a command on exactly the text you just changed, yanked, or pasted, Vim's automatic marks are faster and safer than reselecting manually.
command-line #command-line #marks #indentation #ex-commands #normal-mode
:setlocal errorformat=%f:%l:%c:%m | cexpr system('tool %') | copen
Not every linter or internal script speaks Vim quickfix format out of the box.
command-line #command-line #quickfix #errorformat #linting #workflow
:command! -nargs=* -complete=file W w <args>
When you repeatedly type a long Ex command with filenames, define a user command that keeps the behavior but shortens the keystrokes.
command-line #command-line #ex-commands #completion #workflow
:lgrep /pattern/ % | lopen
Quickfix is global, but sometimes you want a narrower search workspace tied to one window.
:cdo s/foo/bar/ge | update
When quickfix already contains exactly the lines you want to touch, :cdo is the safest way to batch-edit with tight scope.
command-line #command-line #quickfix #substitution #refactoring
:let @/ = '\V' . escape(@0, '\')
When the text you yank contains regex characters, a normal / search can produce noisy or surprising matches.
:%s/pattern/replacement/gn
When you are about to run a broad substitution, it is often safer to measure impact first.
command-line #command-line #ex-commands #substitution #search
:call histdel(':', -1)
When you run sensitive or noisy Ex commands, they stay in command history and can be recalled accidentally.
:argdo update
When working through an argument list, many files may remain unchanged.
command-line #command-line #buffers #ex-commands #refactoring
:let @/ = '\V' . escape(expand('<cword>'), '\')
This pattern lets you prepare a precise search target without jumping the cursor or triggering an immediate search motion.
:%s/\v(\d+)/\=printf('%04d', submatch(1))/g<CR>
When you need to normalize IDs, ticket numbers, or sequence values, :substitute can do more than plain text replacement.
command-line #command-line #substitute #regex #formatting #ex-commands
:%s/\v\d+/\=printf('%04d', submatch(0))/g
When you need aligned numeric data for logs, IDs, or generated fixtures, manual edits are slow and error-prone.
:set nrformats-=octal\<CR>
If you work with IDs, ticket numbers, or zero-padded counters, Vim's default octal behavior can be surprising.
:keepalt edit path/to/file\<CR>
Experienced Vim workflows often depend on the alternate file (#) for fast toggling with , quick diffs, or two-file review loops.
:ldo s/foo/bar/ge | update\<CR>
:ldo is one of the most effective ways to perform targeted, multi-file edits without touching unrelated text.
:%s/\v(\d+)/\=printf('%04d', submatch(1))/g
When you need stable-width numeric fields, manual edits are slow and error-prone.
command-line #command-line #substitution #regex #refactoring
:lockmarks keepjumps keeppatterns %s/\s\+$//e
Bulk cleanup commands are easy to automate, but many implementations quietly damage editor state by moving marks, polluting the jumplist, or replacing your last
cnoreabbrev w!! w !sudo tee > /dev/null %
When you forget to open a file with elevated privileges, quitting and reopening can break your flow.
command-line #command-line #abbreviations #sudo #write #workflow
:vimgrep /{pattern}/j **/*
For project-wide searches, :vimgrep is powerful but can feel disruptive if it jumps into files while populating quickfix.