How do I export the current buffer as syntax-highlighted HTML from within Vim?
:%TOhtml
Vim ships with a built-in plugin that converts the current buffer into a standalone HTML file, complete with your exact syntax highlighting colors.
:%TOhtml
Vim ships with a built-in plugin that converts the current buffer into a standalone HTML file, complete with your exact syntax highlighting colors.
:%s/,/,\r/g
In Vim substitutions, \n and \r behave differently depending on whether they appear in the search pattern or the replacement string — a common gotcha that sur
:execute "normal! \<{key}>"
When building dynamic :execute normal! calls in Vimscript, you must use double-quoted strings with the \ notation so Vim interprets the special key codes.
:center / :right / :left
Vim has built-in Ex commands to align text: :center, :right, and :left.
:[range]normal @a
The :[range]normal @a command runs a recorded macro against every line in a given range.
macros #macros #registers #ex-commands #normal-mode #advanced
:set grepprg=rg\ --vimgrep\ --smart-case
By default, Vim's :grep command calls the system grep.
:set {option}^=value
Vim's :set option^=value operator prepends a value to the front of a list-style option, giving it the highest priority.
:'<,'>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 cmdheight=2
The cmdheight option controls how many lines Vim reserves for the command-line area at the bottom of the screen.
:norm!
The :normal! command (abbreviated :norm!) executes a sequence of Normal mode keystrokes while completely ignoring user-defined mappings and abbreviations.
getreg()
The getreg({name}) function returns the content of any register as a string.
:silent!
The :silent! modifier runs an Ex command without displaying any output or error messages.
\&
Vim's \& operator is the AND combinator in a search pattern.
:e!
:e! forces Vim to reload the current file from disk, discarding every unsaved change in the buffer.
buffers-windows #buffers-windows #editing #undo-redo #ex-commands
:sview {file}
The :sview command opens a file in a horizontal split window with the buffer set to read-only.
buffers-windows #buffers-windows #windows #navigation #ex-commands
:set tags+=./tags;,tags
By default, Vim only looks for a tags file in the current directory.
autocmd BufNewFile *.py 0r ~/.vim/templates/python.py
When you create a new file in Vim (e.
:set define=^\\s*def
Vim's [d, ]d, [D, and ]D commands search for the "definition" of the keyword under the cursor.
:g/^/t.
The command :g/^/t.
:stopinsert
:stopinsert is an Ex command that immediately exits insert (or replace) mode and returns to normal mode.
command-line #insert-mode #ex-commands #autocommands #normal-mode