How do I ROT13 encode text using visual mode in Vim?
g?
Vim has a built-in ROT13 encoding operator accessible via g?.
visual-mode #visual-mode #encoding #rot13 #text-transformation
Search Vim Tricks
Searching...g?
Vim has a built-in ROT13 encoding operator accessible via g?.
visual-mode #visual-mode #encoding #rot13 #text-transformation
:'<,'>!awk '{printf "%-20s %s\n", $1, $2}'
By piping a visual selection through awk with printf formatting, you can align columns to fixed widths.
visual-mode #visual-mode #formatting #alignment #external-command
<C-v>j$A;<Esc>
When lines have varying lengths, a normal visual block selection stops at the shortest line.
<C-v>jjI\=printf('%02d ', line('.')-line("'<")+1)<CR><Esc>
By combining visual block insert with Vim's expression register, you can insert dynamically computed line numbers at the start of each selected line.
visual-mode #visual-mode #block-mode #line-numbers #expression-register
<C-v>jjxp
Visual block mode lets you select, cut, and paste rectangular columns of text.
/\%5l\%10cpattern
Vim provides position-matching atoms that constrain where a pattern can match based on line numbers, column positions, or virtual columns.
/pattern\{3}
Vim supports counted quantifiers that let you specify exactly how many times a pattern should repeat.
/pattern\@<=match
Vim supports zero-width assertions (lookahead and lookbehind) in its regex engine, allowing you to match text based on what precedes or follows it without inclu
:%s/\d\+/\=submatch(0)+1/g
Vim's expression replacement (\=) in substitutions lets you perform arithmetic on matched text.
:%s/\(\w\+\) \(\w\+\)/\2 \1/g
Vim's substitute command supports captured groups (back-references) using \( and \), allowing you to capture parts of a match and rearrange them in the replacem
/[\x00-\x1f]
Files sometimes contain hidden control characters that cause subtle bugs.
/pattern\_s\+next
Vim's regular expressions support multi-line matching through underscore-prefixed atoms.
/[[:digit:][:upper:]]
Vim supports POSIX character classes inside bracket expressions, providing a portable and readable way to match categories of characters.
"+q{keys}q
You can record macros into any register, including the system clipboard (+).
:echo @/
The / register holds the most recent search pattern.
"1pu.u.u.
Vim stores the last 9 deletions in numbered registers 1-9, with the most recent in register 1.
"ayi(
Combining named registers with text object motions lets you precisely yank structured content — like function arguments, quoted strings, or bracketed expressi
:nnoremap <leader>d "=strftime('%Y-%m-%d')<CR>p
The expression register (=) evaluates Vimscript expressions and uses the result as register content.
:echo @%
Vim provides special read-only registers that hold the current and alternate filenames.
@a (within macro @b)
Vim macros can call other macros, enabling modular macro composition.