How do I apply a macro to every non-blank line in the file while skipping empty lines?
:g/./norm @q
Combining the :global command with :normal lets you run a macro on every non-blank line in one shot.
2125 results for "i' a'"
:g/./norm @q
Combining the :global command with :normal lets you run a macro on every non-blank line in one shot.
gq
The gq operator reformats text to fit within your configured textwidth.
:lua =expr
In Neovim, prefixing a Lua expression with = on the :lua command line evaluates it and pretty-prints the result using vim.
: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
[/
When editing code, you often need to navigate to the boundaries of multi-line block comments (/ .
grr
Since Neovim 0.
:%!
The ! operator pipes text through a shell command, replacing the selected lines with the command's output.
"1pu.u.u.
Vim stores the last 9 deletions in numbered registers 1-9, with the most recent in register 1.
:g/pattern/normal @a
The :g (global) command combined with :normal @a lets you execute a recorded macro only on lines matching a pattern.
macros #macros #ex-commands #global-command #editing #automation
/\cfoo
Vim's \c and \C flags let you force a search to be case-insensitive or case-sensitive on a per-search basis, regardless of your ignorecase and smartcase setting
:botright copen 8 | wincmd p
Quickfix is powerful, but opening it can disrupt window layout and yank focus away from your current editing context.
:set switchbuf=usetab,newtab
When you jump to buffers from quickfix, tags, or command-line completions, Vim's default window selection can feel unpredictable.
buffers-windows #buffers #windows #tabs #quickfix #navigation
:keepjumps normal! /\Vtarget\<CR>
Repeated navigational searches can pollute the jump list, especially when you are doing targeted inspections before returning to your main edit location.
navigation #navigation #search #jumplist #normal-mode #workflow
: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
qaI1. <Esc>jq
Start at line 1, record a macro that inserts 1.
<C-v>{motion}~
Visual block mode () selects a rectangular column region, and pressing ~ at the end toggles the case of every character in that exact column range across all se
zr
zr ("reduce" fold level) decrements the global foldlevel option by 1, opening the next layer of folds across the entire file.
:g/^/normal I// <CR>
When you need to comment a whole block quickly, :global combined with :normal is faster than recording a macro or entering Visual Block mode.
:noautocmd w
The :noautocmd modifier runs any Ex command while suppressing all autocmd events for its duration.