All commands below are in normal mode unless specified otherwise.
Hit esc
on keyboard to enter normal mode.
/
search forward, ?
search backward, for example
?text
search backward for the word "text", /text\c
case-insensitive search
:let @/ = ""
clear search context;
:%s/text/replacement/gic
interactive search. y - replace, n - skip, a - all, q - quit, l - replace one and quit
Search for text with /text
, hit enter, then type cgn
to change current selection and then
select next occurrence of the text. Type replacement text and then hit .
to continue to the next occurrence.
You may hit n
before repeating action to see which occurrence you are on. Hit n
once again to skip occurrence.
Same trick can be done with dgn
to delete the text.
:set ignorecase
:set hlsearch
highlight search; :set incsearch
incremental (search as you type)
:set ic hls
is enable all three at once, :set noic nohls nois
disable all three
:noh
clear search highlight until the next search
ctrl + ]
go to;
:vsplit
or :split
to split window; ctrl + w
and then navigation arrows or hjkl
to switch between panels;
ctrl + w + q
or :close
to close panel;
%
go to matching bracket (){}[], *
go to next occurrence of the word under the cursor.
w
go to the next word, e
go to the end of current word.
ctrl + o
go to previous location, ctrl + i
go to next location.
"
then register code then command. "ay
yank to register a
, "ap
paste from register a
.
*
and +
registers are special registers that are used for system clipboard.
"+y
yank to system clipboard, "+p
paste from system clipboard.
Wayland has an issue with *
and +
vim registers.
There's a plugin to fix it and probably vim can be rebuilt to address this.
But so far the easy way to workaround is to use temp file to copy and paste:
Select lines with V
and then hit :
, :'<,'>
will appear, type further to make :'<,'>w! /tmp/vimcp
to copy.
Use :r /tmp/vimcp
to paste from this file. This approach will write whole lines into the file.
To write only the selection do :call writefile(getreg('z', 1, 1), "/tmp/vimcp)
.
terryma/vim-multiple-cursors
works fine in normal vim,
but ideavim only understands alt + n
, alt + x
instead of ctrl + n
and ctrl + x
(skip).