How do I combine multiple Ex commands into a single undo step in Vim?
:undojoin
When writing Vim scripts or running multiple Ex commands, each command normally creates a separate undo entry.
2277 results for "@a"
:undojoin
When writing Vim scripts or running multiple Ex commands, each command normally creates a separate undo entry.
:s/pattern/\=expression/
The \= prefix in the replacement field of :s/// tells Vim to evaluate the right-hand side as a Vim script expression and use the result as the replacement text.
:set viewoptions=cursor,folds,slash,unix
The viewoptions setting is a comma-separated list that determines exactly what :mkview (and the auto-save view pattern) stores in a view file.
:Oil
oil.
:packadd cfilter | Lfilter /pattern/
When you already have a populated location list, rerunning the original search just to focus on a subset is slow and disruptive.
:setlocal nobuflisted
Setting nobuflisted removes a buffer from the :ls output and buffer-switching commands like :bnext/:bprev, while keeping it loaded and accessible.
buffers-windows #buffers-windows #buffers #unlisted #management
:let @q .= "j^"
Live macro recording is fast, but adjusting the tail of a macro by re-recording can be risky once it already works in most places.
macros #macros #registers #automation #normal-mode #workflow
qq /pattern<CR> {commands} q
By incorporating a search command inside a macro, you can make it jump to the next occurrence of a pattern before performing its edits.
cx{motion} … cx{motion} (vim-exchange)
The vim-exchange plugin provides cx{motion} to mark a region, then cx{motion} again on a second region to swap them in place.
:[range]center / :[range]right / :[range]left
Vim has built-in Ex commands for text alignment: :center, :right, and :left.
g'{mark}
Vim's standard mark-jump commands ('a, ` a `) always add the current position to the jumplist before leaping to the mark.
:terminal
The :terminal command opens an interactive terminal emulator directly inside a Vim window.
:X
The :X command sets an encryption key for the current file.
command-line #command-line #security #file-management #ex-commands
:keepalt sbuffer {bufnr}
The alternate-file register (#) is easy to disturb when jumping around buffers, and many advanced motions depend on it (, # expansions, quick two-file toggles).
:cdo s/old/new/ | update
:cdo {cmd} executes a command at every entry in the quickfix list, visiting each location in turn.
:w ++ff=unix
The ++ff modifier on :w forces the file format used for writing, independently of the buffer's 'fileformat' option.
command-line #ex-commands #formatting #command-line #editing
:set path+=** | :find
By adding to Vim's path option and using :find, you can search for any file recursively through your project tree with tab completion — no plugins required.
:'<,'>w {filename}
After making a visual selection, you can write only those lines to a new file using :'w {filename}.
:%s/^/\=line('.').' '/
Vim's substitute command supports expressions in the replacement string using \=.
<C-v>u{code}
In insert mode, followed by u and a 4-digit hex code inserts the Unicode character with that code point.