How do I indent or unindent selected lines in visual mode?
> and <
How it works In visual mode, you can shift selected lines to the right or left using the > and to indent them or or shifts the selected lines one shiftwidth to
> and <
How it works In visual mode, you can shift selected lines to the right or left using the > and to indent them or or shifts the selected lines one shiftwidth to
gaip=
vim-easy-align is a plugin by Junegunn Choi that makes aligning text around delimiters effortless.
r{char} in visual mode
In visual mode, pressing r followed by a character replaces every character in the selection with that single character.
=i{ or =ap
The = operator performs smart indentation based on Vim's filetype-aware indent rules.
:%s/,/\r/g
In Vim's substitute command, \r in the replacement string inserts a newline.
<C-v>u{code}
In insert mode, followed by u and a 4-digit hex code inserts the Unicode character with that code point.
<C-h> / <C-w> / <C-u>
Vim provides three levels of deletion directly in insert mode, so you don't need to switch to normal mode for small corrections.
Write keystrokes in buffer, then "qy$
Instead of recording a macro in real-time (where mistakes mean starting over), you can write the keystrokes as text in a buffer, edit them visually, and then ya
macros #macros #editing #registers #workflow #best-practices
q: or <C-f> from : prompt
The command-line window (q:) opens a full Vim buffer containing your Ex command history.
gU{motion} / gu{motion} / g~{motion}
Vim has three case operators that work with any motion or text object: gU for uppercase, gu for lowercase, and g~ for toggle case.
editing #editing #case #operators #text-objects #normal-mode
ggVG
While Vim doesn't have a built-in "entire buffer" text object, the ggVG sequence achieves it: go to the first line, enter line-wise visual mode, then select to
:earlier 5m
Vim's :earlier and :later commands let you travel through your undo history using time-based offsets — not just individual changes.
* then :%s//new/g
Pressing searches for the word under the cursor, which also loads it into the search register.
:%sort u
The :sort u command sorts all lines in the file and removes duplicate lines in one operation.
command-line #command-line #ex-commands #editing #text-manipulation #sort
( / ) / { / }
Vim treats sentences and paragraphs as first-class navigation units.
navigation #navigation #motions #text-objects #prose #editing
:'a,'b s/old/new/g
Marks can be used as range specifiers in any Ex command.
command-line #marks #command-line #ex-commands #ranges #editing
gJ
The gJ command joins the current line with the line below it without inserting any space between them.
<C-a> / <C-x>
Pressing increments and decrements the number under or after the cursor.
ga
The ga command displays the ASCII/Unicode value of the character under the cursor in decimal, hexadecimal, and octal.
editing #editing #unicode #debugging #normal-mode #inspection
:g/pattern/m$
The :g (global) command combined with :m (move) relocates all matching lines to a specified destination.
command-line #command-line #ex-commands #global #editing #organization