How do I edit a binary file in hex mode using Vim?
:%!xxd
Vim can serve as a hex editor by piping buffer contents through xxd, a hex dump utility that ships with Vim.
:%!xxd
Vim can serve as a hex editor by piping buffer contents through xxd, a hex dump utility that ships with Vim.
<C-v>jj$A;
Visual block mode normally selects a fixed-width column, which makes appending tricky when lines have different lengths.
qaqqa{actions}@aq@a
A recursive macro is a macro that calls itself at the end of its recording.
:/start/,/end/ {command}
Vim's range addressing lets you specify a line range using search patterns instead of explicit line numbers.
:<C-r>"
When typing an Ex command or search pattern, you often need to insert text you've already yanked or deleted.
:set nrformats+=hex,bin
By default, Vim's and only increment and decrement decimal numbers.
crs / crm / crc / cru
Tim Pope's vim-abolish plugin provides cr (coerce) commands that instantly convert the word under the cursor between common naming conventions.
gqap
The gq operator reformats text by wrapping lines to fit within the textwidth setting.
: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.
o (in Visual mode)
When you make a Visual selection in Vim, the cursor sits at one end while the other end is anchored.
/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.
"1p then u then . to cycle
Vim stores your last 9 deletions in numbered registers "1 through "9.
>gv
Normally, pressing > in visual mode indents the selection but exits visual mode, requiring you to press gv to reselect.
<C-v>j$A;<Esc>
When lines have varying lengths, a normal visual block selection stops at the shortest line.
<C-v>jjxp
Visual block mode lets you select, cut, and paste rectangular columns of text.
:move +1 / :move -2
The :move command relocates lines to a specific position without using delete and paste.
:%norm A;
The :%norm command runs normal mode commands on every line in the file (or a range).