How do I center or right-align lines of text using Vim's built-in Ex commands?
:%center 80
Vim has three built-in Ex formatting commands — :left, :center, and :right — that align text within a specified column width.
:%center 80
Vim has three built-in Ex formatting commands — :left, :center, and :right — that align text within a specified column width.
:set formatoptions+=a
Vim's formatoptions setting controls how automatic text formatting works.
:set nojoinspaces
By default, Vim follows an old typesetting convention and inserts two spaces after a period, exclamation mark, or question mark when joining lines with J.
:[range]right [width]
Vim's :right command right-aligns text by padding lines with leading spaces up to a given width.
:[range]center {width}
Vim has a built-in :center command that pads lines with leading spaces to visually center them within a given column width.
command-line #formatting #text-alignment #ex-commands #editing
:set fillchars+=vert:│,fold:·
The fillchars option controls the filler characters Vim uses for various UI elements — window separators, fold fill lines, diff padding, and more.
:[range]center
Vim provides three Ex commands for aligning text within a specified column width: :[range]left, :[range]center, and :[range]right.
command-line #ex-commands #formatting #editing #command-line
:set equalprg={program}
The equalprg option replaces Vim's built-in = indentation operator with any external formatting program.
:center / :left / :right
Vim has three built-in Ex commands for aligning text without any plugins: :left, :center, and :right.
vipgq
The vipgq sequence reflowing a paragraph to fit within the width defined by textwidth (default 0, meaning no limit).
:{range}center [width]
Vim provides three built-in Ex commands for text alignment: :center, :right, and :left.
:right
Vim has three built-in Ex commands for text alignment that most users never discover: :right [width] right-justifies lines, :left [width] left-justifies (strips
:g/./,/^$/join
Hard-wrapped text (where each sentence is on its own line) is common in commit messages, email threads, and older documentation.
gw{motion}
The gw operator reformats text just like gq, but leaves the cursor exactly where it started.
:g/^$/,/./-j
The command :g/^$/,/.
:[range]right {width}
Vim has built-in Ex commands for text alignment — :right, :left, and :center — that work over any line range without plugins.
command-line #formatting #indentation #command-line #ex-commands
:set formatoptions+=j
Adding the j flag to formatoptions causes Vim to strip the comment leader from the second line when two comment lines are joined with J.
:'<,'>center / :'<,'>right / :'<,'>left
Vim has built-in Ex commands to align text within a specified width: :center, :right, and :left.
crs / crc / crm / cru
The vim-abolish plugin adds coercion operators that instantly convert the word under the cursor between common naming conventions.
plugins #editing #text-objects #plugins #normal-mode #formatting
:set formatoptions-=cro
By default, Vim continues the current comment leader when you press in insert mode or open a new line with o/O.