How do I use a register value as the replacement string in a substitution?
:%s/pattern/\=@a/g
How it works In Vim's substitute command, the replacement string can be a Vimscript expression when prefixed with \=.
:%s/pattern/\=@a/g
How it works In Vim's substitute command, the replacement string can be a Vimscript expression when prefixed with \=.
:@a
How it works The command :@a executes the contents of register a as an Ex command.
try | colorscheme gruvbox | catch | colorscheme default | endtry
How it works When you share your vimrc across multiple machines, a colorscheme you have installed on one system may not exist on another.
"*p vs "+p
How it works Vim has two system clipboard registers that interact with the operating system: " -- the selection register (PRIMARY selection on Linux/X11, clipbo
:set backupdir=~/.vim/backup// directory=~/.vim/swap//
How it works By default, Vim creates backup files (ending in ~) and swap files (ending in .
:set autowriteall and autocmd FocusLost * silent! wa
How it works Vim can be configured to automatically save your files when you switch to another window or application.
:set ignorecase smartcase
How it works By setting both ignorecase and smartcase, Vim uses an intelligent case sensitivity rule for searches: If your search pattern is all lowercase, the
:set showmatch
How it works The :set showmatch option makes Vim briefly jump the cursor to the matching opening bracket when you type a closing bracket.
:<C-r>a
How it works While typing an Ex command on the command line (after pressing :), you can insert the contents of any register by pressing Ctrl-R followed by the r
:{line}put {register}
How it works The :put Ex command pastes the contents of a register after a specified line.
:set mouse=a
How it works The :set mouse=a command enables mouse support in all Vim modes.
:%s/\<word\>/replacement/g
How it works In Vim's regular expressions, \ are word boundary anchors: \ matches the end of a word.
"add
How it works When you delete text in Vim with commands like dd, dw, or x, the deleted text goes into the unnamed register and the numbered registers (1-9).
:iabbrev {abbr} {expansion}
How it works The :iabbrev command creates abbreviations that automatically expand when you type them in insert mode.
:m {address}
How it works The :m command (short for :move) moves one or more lines to after the specified address.
:g/pattern/t$
How it works The :g (global) command combined with :t (copy) lets you duplicate all lines matching a pattern to a specific location.
:t {address}
How it works The :t command (short for :copy) copies one or more lines and places them below the specified address.
"ayy "byy "cyy
How it works Vim provides 26 named registers (a through z) that you can use as independent clipboards.
: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
:'<,'>w filename
How it works Vim's :w command can take a range, and when used with a visual selection, it writes only the selected lines to a file.