How do I convert all numbers to fixed-width zero-padded values in Vim?
:%s/\v\d+/\=printf('%04d', submatch(0))/g
When you need aligned numeric data for logs, IDs, or generated fixtures, manual edits are slow and error-prone.
105 results for "buffer number"
:%s/\v\d+/\=printf('%04d', submatch(0))/g
When you need aligned numeric data for logs, IDs, or generated fixtures, manual edits are slow and error-prone.
:set spell
The :set spell command activates Vim's built-in spell checker, which highlights misspelled words directly in your buffer.
:'<,'>s/^/\=line('.')-line("'<")+1 . '. '/
When you need quick numbered steps, logs, or checklist entries, this pattern adds numbers only to the lines you selected, not the whole buffer.
vim.print()
vim.
:[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
]q and [q
The vim-unimpaired plugin by Tim Pope provides pairs of bracket mappings for common navigation and toggling tasks.
:set foldmarker=region,endregion
When using foldmethod=marker, Vim looks for the strings in foldmarker to identify fold boundaries.
:'<,'>sort n
By default, :sort in Vim uses lexicographic (alphabetical) ordering, so "10" sorts before "2" because "1" sort n — sort selected lines by the leading number,
:s/\v(\w+) (\w+)/\2 \1/
Vim's substitute command supports capture groups using \( and \) (or ( and ) in \v very-magic mode).
:windo setlocal colorcolumn=+1
When a setting is window-local, changing it once does not affect your other splits.
:set viewoptions-=options
When you use :mkview and :loadview, Vim stores more than folds and cursor position.
searchcount()
The searchcount() function returns a dictionary containing the current search state: which match the cursor is on, how many total matches exist, and whether the
dp / do
When reviewing differences between files in Vim's built-in diff mode, dp and do let you selectively apply individual hunks without leaving the editor.
<C-w>gf
gf reads the filename under the cursor and opens it in a new tab page, keeping your current buffer untouched.
{count}go
The go command moves the cursor to a specific byte offset from the start of the buffer.
:retab
How it works The :retab command replaces all tab characters in the current buffer with the appropriate number of spaces, based on your current tabstop and expan
"=expression<CR>p
The expression register ("=) lets you evaluate any Vimscript expression and paste the result directly into your buffer from normal mode.
registers #registers #editing #normal-mode #productivity #math
<C-o>
The (Ctrl+o) command jumps the cursor backward through the jump list, returning you to previous cursor positions.
:tabnew filename
The :tabnew filename command opens a file in a new tab page in Vim.
buffers-windows #buffers-windows #tabs #ex-commands #navigation
:set nowritebackup
By default, Vim saves files using a "write-then-rename" strategy: it writes to a temporary backup file and then renames it over the original.