Made by Max Modesto Wallin
- : (ex command)
- :h :r
- none (normal)
- :h r
- v_ (visual)
- :h v_r
- i_ (insert mode)
- :h i_CTRL-W
- c_ (ex command line)
- :h c_CTRL-R
<C-E>
- Scroll window down
<C-Y>
- Scroll window up
<C-F>
- Scroll one page down
<C-B>
- Scroll one page up
H
- Put cursor in window top
M
- Put cursor in window middle
L
- Put cursor in window bottom
gg
- Put cursor in file top
G
- Put cursor in file bottom
w
- Word forward start
e
- Word forward end
b
- Word backward start
ge
- Word backward end
f
- Find forward
F
- Find backward
t
- Until forward
T
- Until backward
a
- All (including motion's surroundings)
i
- In (inside motion)
g { movement }
- Navigates wrapped text
<C-i>
- Traverses through the jumplist (next)
<C-o>
- Traverses through the jumplist (previous)
<C-t>
- Jump to
count
older entry in the tag stack
- Jump to
v
v
toggles inclusiveness.- Example "Hello World" when being at the end of the line
dT<Space>
would result in "Hello d"dvT<Space>
would result in "Hello "- This works because T is
exclusive
, see :h t
I
- Put cursor in beginning of line and enter insert mode
A
- Put cursor in end of line and enter insert mode
D
- Delete until end of line
C
- Delete until end of line and enter insert mode
<C-O>
- Leaves input mode for one command
<C-P>
- Opens completion menu
<C-a>
- Insert from . register (dot register)
<C-r>
- Insert from register, example
<C-r>h
to insert from register h
- Insert from register, example
<C-O>
- Leaves input mode for one command
<e>
- Close popup
<C-x><C-n>
- Current file (next)
<C-x><C-p>
- Current file (previous)
<C-x><C-f>
- Filename
<C-x><C-n>
- Completion of anything specified by context, set with complete
- Explanation:
- . (this file)
- w (other windows)
- b (other buffers)
- u (unloaded other buffers)
- t (tags file)
- t (included files, such as imports and language specifics)
<C-x><C-l>
- Line (context aware)
<C-x><C-]>
- Tag
~
- Toggle case of the character under the cursor
g~~
- Toggle case of whole line
g~{motion}
- Toggle case of the motion
gU{motion}
- Change the motion to uppercase
gUU
- Change the current line to uppercase
gu{motion}
- Change the motion to lowercase
guu
- Change the current line to lowercase
- Find
- Type
\
for forward search or?
for backward search- Prepend search pattern with \v for case insensitive search
- Type
- Replace
- Using sed,
%s/pattern/replace/g
- % can be exchanged for any range
- The g means global, continue search for whole lines
- Using sed,
- Find file
- Use find command with regex expression and tab through the results,
:find *expression<TAB>
- Use find command with regex expression and tab through the results,
- Find inside files
- Using grep command
- Examples:
:grep -Fr '.ad' */.css
- Finds
class
ad in css files - -F to pass literal string, else it'd be interpreted as regex
- -r for recursive search
- Finds
:grep -ERi '\=\=\= [a-z]{4}\s' */.js
- Finds
=== true
- -i for case insensitive search
- Finds
:grep -r --exclude-dir=node_modules 'some pattern' /path/to/search
- Finds
some pattern
in/path/to/search
, excluding the dir node_modules
- Finds
- Examples:
- Traversing the results
:cnext
orö-q
and:cprev
orä-q
to traverse forward/backward:copen
and:cclose
are used to open/close the quickfix list
- Using grep command
- Replace inside files (refactor)
- Use Ack to grep inside project and populate the results in the quickfix list
- Use
:cdo
to execute a command on the entries in the quickfix list update
is like write, but only updates the buffer that's modified'- Example:
- :Ack foo
- :cdo s/foo/bar/g | update
@a
- Executes macro a on current line
:5,10norm!@a
- Executes macro a on lines 5-10@
:g/pattern/norm!@a
- Executes macro a on matching pattern
:%norm!@a
- Executes macro a on whole file
gcc
- Comment/uncomment line
gc{motion}
- Comment/uncomment motion
If the opening mark is used, whitespace is added
ds"
- Delete surrounding "
cs])
- Change surrounding ] to )
cs]<q>
- Change surrounding ] to )
ysw(
- Add
(
around word and add white space
- Add
yss)
- Wraps the whole line with
(
- Wraps the whole line with
{count}ö<space>
- Prepend with {count} line(s)
{count}ä<space>
- Append with {count} line(s)
{count}öe
- Move line up {count} line(s)
{count}äe
- Move line down {count} line(s)
<C-y>,
- Expands emmet before the cursor, for example html:5_ (_ is the cursor position)