How do I visually display tabs, trailing spaces, and end-of-line characters in Vim?
:set list listchars=tab:>-,trail:~,eol:$
Enabling list mode makes Vim render normally invisible characters using configurable symbols defined in listchars.
:set list listchars=tab:>-,trail:~,eol:$
Enabling list mode makes Vim render normally invisible characters using configurable symbols defined in listchars.
set colorcolumn=+1
The colorcolumn option highlights one or more vertical columns to help keep lines within a length limit.
:ce
Vim has three built-in ex commands for text alignment that most users never discover: :ce (center), :ri (right-justify), and :le (left-justify).
:set concealcursor=nvi
When 'conceallevel' is 2 or higher, Vim hides syntax markers—turning raw Markdown like bold into visual bold or collapsing LaTeX commands.
:{range}center {width}
Vim has built-in Ex commands for text alignment: :center, :right, and :left.
command-line #ex-commands #formatting #editing #command-line
gq{motion}
The gq{motion} operator reformats text to fit within Vim's textwidth setting, inserting hard line breaks where lines are too long.
:set showbreak=+++
When wrap is enabled, Vim wraps long lines at the screen edge, but there is no built-in visual marker to distinguish a wrapped continuation from a brand-new lin
:center / :right / :left
Vim has built-in Ex commands to align text: :center, :right, and :left.
:'<,'>right {width}
The :right Ex command right-aligns lines within a given column width by padding them with spaces on the left.
visual-mode #visual-mode #formatting #ex-commands #alignment
:set commentstring=//\ %s
The commentstring option controls the template Vim uses to represent commented-out lines.
:set statuscolumn=%s%=%l\
Neovim 0.
config #config #neovim #statusline #line-numbers #formatting
vim.lsp.buf.format()
Neovim's built-in LSP client exposes vim.
:set formatexpr=MyFormat()
The formatexpr option lets you replace Vim's built-in line-breaking logic for the gq operator with your own Vimscript expression or function.
gUU
The gUU command uppercases every character on the current line instantly — no visual selection or motion required.
:%s/\n/ /g
Using \n in the pattern of :substitute matches the newline character at the end of each line, letting you join lines with any separator you choose — something
:setfiletype {filetype}
:setfiletype {filetype} sets the filetype option for the current buffer only if it has not already been set.
:set formatprg=<cmd>
When formatprg is set, the gq operator pipes the selected text through that external program and replaces it with the program's output.
gw
The gw operator reformats text to fit within textwidth, just like gq — but with one key difference: gw leaves the cursor in its original position after format
:set display=lastline
By default, when the last visible line of a window is too long to fit on screen, Vim shows @@@ in its place — hiding the content entirely.
:set formatprg={program}
Vim's gq operator normally reflows text to fit textwidth, but by setting formatprg you can delegate formatting to any external tool — a language formatter, a