How do I join a specific range of lines into one line using an Ex command?
:[range]join
The :[range]join Ex command lets you join lines by specifying an explicit line range — without having to navigate there or use visual selection.
:[range]join
The :[range]join Ex command lets you join lines by specifying an explicit line range — without having to navigate there or use visual selection.
:[range]center / :[range]right / :[range]left
Vim has built-in Ex commands for text alignment: :center, :right, and :left.
:set formatoptions
The formatoptions setting is a string of single-character flags that governs Vim's automatic text formatting: when lines wrap, whether comment syntax continues
:[range]center [width]
Vim's built-in :left, :center, and :right Ex commands align text without plugins or external tools.
:set equalprg=gofmt
By default, Vim's = operator re-indents text using its internal rules.
config #config #editing #ex-commands #formatting #indentation
!{motion}{cmd}<CR>
In normal mode, !{motion} sends the lines covered by the motion to a shell command's stdin and replaces them with stdout.
:sort n
:sort n sorts lines by the first number found on each line, comparing values numerically rather than as strings.
:center, :right, :left
Vim includes three built-in Ex commands for text alignment that most users never discover: :center, :right, and :left.
:'<,'>center
After making a visual selection, typing : automatically inserts ' to scope the command to the selection.
visual-mode #visual-mode #formatting #ex-commands #indentation
gR
gR enters Virtual Replace mode, a smarter variant of Replace mode (R) that replaces characters based on screen columns rather than raw bytes.
gwip
The gw operator reformats text just like gq, but leaves the cursor in its original position after reformatting.
gq (visual mode)
Pressing gq on a visual selection reformats the selected lines to hard-wrap at textwidth columns.
= (in visual mode)
After making a visual selection, pressing = applies Vim's auto-indent to every selected line at once.
:%s/pattern/\U&/g
Vim's substitute replacement string supports special case-transform atoms that change the case of matched text without requiring a second pass or an external to
!{motion}{command}
The ! operator filters the text covered by a motion through an external shell command, replacing the original lines with the command's stdout.
:sort u
The :sort u command sorts all lines in the buffer (or a selected range) alphabetically and removes duplicate lines in a single pass.
:%sort /[^,]*,/ n
Vim's :sort command accepts a pattern that controls which part of each line is used as the sort key.
!{motion}{program}
The ! operator in normal mode lets you pipe a range of text through any external program and replace it with the output.
:%s/^/\=line('.').' '/
Vim's substitute command supports expressions in the replacement string using \=.
<C-v>jjlU
Visual block mode lets you select rectangular regions of text, which means you can target a specific column and apply case changes only to that area.