/[pattern]
search forward for pattern?[pattern]
search backward for patternn
repeat search forwardN
repeat search backward*
search for word currently under cursorg*
search for word partially under cursor[I
show lines with matching word under cursor%s/background/&-color/g
find and replace background with background-color.&
inserts the matched pattern%s/\(foo\)bar/\1baz/g
find and replace foobar with foobaz.\1
uses the captured groupfoo
from the\(\)
%s/yolo/swag/gc
find and replace yolo with swag and ask for confirmation.c
asks for confirmation\zs
and\ze
in substitute command to ignore pattern before and after respectively .
" foobar -> foobaz
%s/foo\zsbar/baz/
" foobar -> bazbar
%s/foo\zebar/baz/
- search across the project with fzf, this will open a quick fix window with the results. Select the ones to be replaced with tab. Press enter. Run the following command to replace
yolo
withyoloswag
in the selected files:cfdo %s/yolo/yoloswag/g | update
:w !sudo tee %
:earlier 15m
g- and g+
go backward and forward in time.g,
to move forwards through the changelist.g;
to move backwards through the changelist.
:! [command]
Executes an external command while you're in Vim.:.! [command]
Executes an external command and dump the results into the buffer eg::.! date
(ctrl + w) + R
move windows up/left(ctrl + w) + r
move windows down/right(ctrl + w) + L
Move the current window to the "far right"(ctrl + w) + H
Move the current window to the "far left"(ctrl + w) + J
Move the current window to the "very bottom"(ctrl + w) + K
Move the current window to the "very top"(ctrl + w) + x
Exchange current window with next one. If there is no next window, exchange with previous
diw
delete the current worddat
delete everything inside html tag, and the tag itselfdi
delete within limiters. Eg:di{
,di[
,di'
,di(
,di<
dd
delete linedt
delete until. Eg:dt"
,dt<space>
df
delete until, and including. Eg:df"
,df<space>
D
delete rest of the line to the right of the cursor
ciw
change current wordcat
change everything inside html tag, and the tag itselfci"
change within limiters. Eg:ci{
,ci[
,ci'
,ci(
,ci<
cc
change current linect
change until. Eg:ct"
,ct<space>
cf
change until, and including. Eg:cf"
,cf<space>
C
change rest of the line to the right of the cursor
yiw
copy current wordyat
copy everything inside html tag, and the tag itselfyi"
yank within limiters. Eg:yi{
,yi[
,yi'
,yi(
,yi<
yy
yank current lineyt
yank until. Eg:yt"
,yt<space>
yf
yank until, and including. Eg:yf"
,yf<space>
Y
yank rest of the line to the right of the cursor
ctrl + v
start visual block, pressj
ork
to select the lines, pressI
(capital i) type text desired, press<ESC>
:%TOhtml
:ls
List opened buffers:bd
close current buffer append!
to force closing buffer after unsaved changes were made:bd[Number]
to close a buffer by number:bw
close and save current buffer:bw[Number]
to close and save a buffer by number
ctrl + x
decrease the number under the cursorctrl + a
increase the number under the cursor
gv
repeat lst visual selection
cs"'
change the surroudning pairs ie. double quotes to single quotescs'<q>
change surrounding single quotes to html tag<q>
cst"
change a surrounding tag to double quoteds"
delete surrouding pairs, ie double quotesysiw]
surround only the word under the cursor, using[
,{
, etc will add spaces between the word and the surroundingyss)
surround the entire line with parentheses- On visual mode, surround selection
S<p class="important">
windo diffthis
uses vimdiff between two opened buffers and compares themwindo diffoff
stop vimdiff