s/^\d\+/\=(submatch(0)+1)/
To increment anywhere within lines:
s/^filler text \zs\(\d\+\)/\=(submatch(0)+1)/
In visual mode, highlight the text and enter:
gq
In visual mode, highlight the text and enter:
%j
By default, vim will default to a 256-color palette. To enable more colors, add the following to your vimrc:
set termguicolors
If you don't find MiniBufferExplorer useful and want to disable it, add to your vimrc:
let g:miniBufExplAutoStart=0
If all you want is to disable the addon from showing by default in diffs, you can instead add:
let g:miniBufExplHideWhenDiff=0
To break a list of space- or otherwise-delimited items into a list with one item on each line, run:
%s/ /\r/g
To select a whole paragraph or function, move the cursor to within the block of interest and type:
vip
The section is demarcated by empty lines above and below.
To remove color escape sequences from files, such as in text files generated by
logging colorized terminal stdout
, use:
s/�[\x;[0-9;]*m//g
To understand the meanings of various key notations, use Vim's help
utility.
:help key-notation
Add | only
to the end of the :help ...
command to fill the window with the
contents of the help file.
:terminal <command> %
Some plugins my override the formatexpr
variable to execute a custom function.
This will override the default behavior, which is to break text along the
textwidth
variable. To reverse this, run:
set formatexpr=
To always ensure that formatexpr
is unset, add an autocmd rule to the vimrc
file.
Use [s
and ]s
to iterate through all the misspelled words identified by Vim.
Requires that set=spell
is enabled.
Vim can open stdin into a buffer, but it will not be named. To set the name from the command line, pipe to Vim as follows:
cmd ... | vim - +'file <path>'
where <path>
is the location to write the buffer when saving.
Note that opening Vim in this manner will prevent any filetype detection and thereby disable syntax highlighting.
To send the entire buffer to an external program, run:
:%!<cmd>
where <cmd>
is the program to run, including all command line flags, etc.
The selected text will be passed to the program via stdin
and replaced in the
buffer with the program output.
To instead send a selection instead of the entire buffer, select the block of text in visual mode and then enter the command:
:'<,'>!<cmd>