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
: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
:%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
:%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.
: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
:filter /{pattern}/ history cmd
When command history gets crowded, scanning :history cmd manually is slow.
:verbose autocmd BufWritePre
When a save hook starts behaving unexpectedly, the hard part is usually finding who defined it.
:cfdo %s/\<GetUser\>/FetchUser/ge | update
When quickfix has many matches per file, :cdo can execute your command repeatedly in the same buffer.
command-line #command-line #quickfix #refactoring #ex-commands #search
:keepalt edit {file}<CR>
The alternate-file mark (#) powers fast toggles like and commands that depend on the previous file context.
command-line #command-line #buffers #workflow #navigation #advanced
:set showcmdloc=statusline
When you chain operators and motions, showcmd feedback is critical, but the default bottom-line location can fight with command messages and prompts.
:argdo %s/\<old\>/new/ge | update
When you need to apply the same substitution across a curated set of files, :argdo is safer than a broad project-wide command.
command-line #command-line #ex-commands #search #buffers #formatting