How do I run a normal mode command on every line matching a pattern?
:g/pattern/normal dd
The :g/pattern/normal {commands} command executes normal mode keystrokes on every line in the file that matches the given pattern.
2125 results for "i( a("
:g/pattern/normal dd
The :g/pattern/normal {commands} command executes normal mode keystrokes on every line in the file that matches the given pattern.
= (in visual mode)
After making a visual selection, pressing = applies Vim's auto-indent to every selected line at once.
:tabdo only
When you are deep in a refactor, each tab can accumulate helper splits, previews, and temporary views.
buffers-windows #buffers #windows #tabs #ex-commands #workflow
:[range]normal @q
The :[range]normal @q command replays the macro in register q on every line within a given range.
<C-r>-
In insert mode, - pastes the contents of the small delete register ("-).
:set nofixendofline
By default, Vim enforces POSIX compliance by appending a final newline to any file that lacks one.
<C-a> / <C-x> (vim-speeddating)
vim-speeddating (by Tim Pope) extends Vim's built-in and increment/decrement operators to understand dates, times, roman numerals, and other ordered sequences.
cr
The vim-abolish plugin (by tpope) provides a cr (coerce) operator that converts the word under the cursor between naming conventions with a single keystroke pai
{count}go
The go command moves the cursor to a specific byte offset from the start of the buffer.
:put =strtrans(@q)<CR>
Macro failures are often caused by hidden control keys like , , or tabs that are hard to see in raw register output.
:command -range {Name} ...
Custom Ex commands defined with :command -range can be called with a line range (e.
:lua = {expression}
In Neovim, :lua = expr is a shorthand that evaluates a Lua expression and pretty-prints the result using vim.
:sandbox {command}
Vim's sandbox mode restricts what a command can do, preventing it from executing shell commands, writing files, or modifying certain settings.
<C-r>=2+2<CR>
The expression register (=) in insert mode lets you evaluate any Vimscript expression and insert the result inline.
:packadd termdebug | Termdebug
For quick debugging without leaving Vim, the built-in termdebug plugin wires a GDB session directly into your editing workflow.
:g/^./,/^$/join
The :g/^.
command-line #command-line #editing #global #formatting #paragraphs
@+
In Vim, @{register} executes the contents of any register as a macro.
ysiwf
vim-surround's f and F surrounds let you wrap any text object inside a function call, prompting you for the function name.
:lvimgrep /\<TODO\>/gj **/* | lopen
If you want project-wide search results without polluting the global quickfix list, use a location list.
:tab drop filename
When working with many tabs, you often want to open a file — but only if it is not already open somewhere.