How do I run commands without disturbing my marks?
:lockmarks
Many Ex commands silently adjust or delete marks as a side effect of modifying buffer content.
:lockmarks
Many Ex commands silently adjust or delete marks as a side effect of modifying buffer content.
:profile start profile.log | profile func *
When Vim feels sluggish during editing—not just at startup—you need runtime profiling to pinpoint which functions are consuming the most time.
config #profiling #debugging #config #ex-commands #performance
:ls +
The :ls command (or :buffers) supports filter flags that narrow the buffer list to specific states.
:%s/\<\w\+\>/\=toupper(submatch(0))/g
The \= flag in the replacement part of :substitute tells Vim to evaluate what follows as a Vimscript expression instead of treating it as a literal string.
:g/pattern/normal A;
The :global command combined with :normal lets you execute arbitrary normal mode keystrokes on every line that matches a pattern.
command-line #global #normal-mode #editing #ex-commands #batch-editing
:profile start /tmp/profile.log | profile func *
When Vim feels sluggish during editing (not just at startup), the :profile command lets you measure the execution time of every function call.
:&&
After running a :s/pattern/replacement/g command, you often need to repeat it on another line or range.
:cfdo %s/old/new/ge | update
When you grep across your project and want to perform a search-and-replace on every file that matched, :cfdo is the most efficient approach.
command-line #quickfix #substitute #search #ex-commands #editing
:%!xxd
Vim can serve as a hex editor by piping buffer contents through xxd, a hex dump utility that ships with Vim.
:cexpr system('command')
The :cexpr command parses any expression into the quickfix list using the current errorformat.
:/start/,/end/ {command}
Vim's range addressing lets you specify a line range using search patterns instead of explicit line numbers.
vim --startuptime /tmp/vim-startup.log
When Vim takes too long to start, the --startuptime flag writes a detailed timing log showing exactly how long each plugin, script, and initialization step take
:g/pattern/m $
The :g (global) command combined with :m (move) lets you collect all lines matching a pattern and relocate them to a specific position in the file.
command-line #ex-commands #editing #global #search #formatting
/\vfoo\zsbar\ze/
Vim's \zs (start of match) and \ze (end of match) atoms let you control which portion of a pattern is treated as the actual match.
:%Subvert/old{,s}/new{,s}/g
Tim Pope's vim-abolish plugin provides the :Subvert command (aliased as :S), which performs substitutions that automatically preserve case variants and handle p
plugins #plugins #substitution #editing #ex-commands #search
:let @+ = @"
Vim's :let @{reg} syntax lets you read from one register and write to another.
:filter /pattern/ command
The :filter command restricts the output of another Ex command to only lines matching a given pattern.
/pattern\zs.*\ze/
Vim's \zs (start of match) and \ze (end of match) atoms let you define a search pattern but only highlight or operate on a portion of it.
:/start/,/end/command
Vim allows pattern-based ranges in Ex commands, letting you operate on lines between two search matches.
<C-f> (from command-line mode)
When you are partway through typing a long or complex Ex command on the : prompt, you can press to open the command-line window.