Vim quicktip #6: Use NeoVim’s inccommand
option for live substitutions.
:set inccommand=nosplit
shows substitutions happening as you type, and :set inccommand=split
adds a preview window to show off-screen replacements.
Vim quicktip #6: Use NeoVim’s inccommand
option for live substitutions.
:set inccommand=nosplit
shows substitutions happening as you type, and :set inccommand=split
adds a preview window to show off-screen replacements.
Vim quicktip #5: gq{motion}
wraps lines to fit the configured textwidth (:set textwidth
). If textwidth is not set, #vim will use the screen width (with a maximum of 79).
Use gqq
to format the current line, or gq
in visual select mode to format all selected lines.
This is especially useful to make sure the lines in your commit messages aren’t longer than 72 characters. vim-fugitive automatically sets the textwidth option to 72 when writing a commit message with :Gcommit
.
Vim quicktip #4: Vim detects a file’s type by its filename, but you can set the type yourself using the filetype
(or ft
) option. :set ft=elixir
enables syntax highlighting and automatic indentation for Elixir in the current buffer, without having to save the file to disk.
Vim quicktip #3: Press gx
to open a link under the cursor in your web browser.
Vim quicktip #2: A substitution with an empty search pattern replaces matches from the last search. After finding “foo” (/foo
) in the file, you can replace all occurrences with :s//bar/
.
Vim quicktip #1: Use %
to jump between brackets. This works for ()
, {}
, and []
by default, but can be changed using :set matchpairs
.
Plugins like vim-elixir and vim-ruby add b:match_words
like do
, end
and else
, to quickly jump to a block’s end
, for example.