h/j/k/l - cursors
disable VsVim: Alt+Ctrl+Shift+F12
- For the first argument, this key-combination goes to opening parenthesis, and deletes everything up to the next comma,
including the space after it:
T(df,x
- For a middle argument, this key-combination goes to the previous comma, and deletes it and everything until the next comma:
F,dt,
- For the last argument, this key-combination goes to the previous comma, and deletes it and everything until the closing parenthesis:
F,dt)
w
: jump to the beginning of the next _W_ord
b
: (B_ack) to jump to the beginning of a word backwards
e
: (E_nd) to jump to the end of a word
ge
: to jump to the (E_nd) of a word backwards
f{character} | F{character}
= (F_ind)
;
- to go to the next occurrence of the character or
,
- to go to the previous one
; | ,
= After using f{character}
you can type ;
to go to the next
occurrence of the character or ,
to go to the previous one. You can see the ;
and ,
as commands for repeating the last character search.
t{character} | T{character}
= (un_T_il)
/{pattern}
: to search forward inside a file
?{pattern}
: to search backwards
0
: moves to the first character of a line
^
: moves to the first non-blank character of a line
$
: moves to the end of a line
g_
: moves to the non-blank character at the end of a line
}
: jumps entire paragraphs downwards
{
: similarly but upwards
CTRL-D
: lets you move down half a page by scrolling the page
CTRL-U
: lets you move up half a page also by scrolling
/{pattern}
: to search forward inside a file
?{pattern}
: to search backwards
/<Enter>
or ?<Enter>
: run the last search (forwards or backwards).
*
to do a search for the word under the cursor (# to do the same backwards).
{count}{motion}
: [2w,5j,3;,2/baby,2/cuc]
- counts are numbers which let you multiply the effect of a command
gg
: to go to the top of the file.
{line}gg
: to go to a specific line.
G
: to go to the end of the file.
%
: jump to matching ({[]})
gd
: to jump(g_o) to d_efinition of whatever is under your cursor.
gf
: to jump(g_o) to a f_ile in an import.
{operator}{count}{motion}
{count}{operator}{motion}
c
(c_hange): Change
y
(y_ank): Copy in Vim jargon
p
(put): Paste in Vim jargon
g~
(switch case): Changes letters from lowercase to uppercase and back. Alternatively, use gu
to make something lowercase and gU
to make something uppercase
gu
- lowercase
gU
- uppercase
>
: (shift right): Adds indentation
<
(shift left): Removes indentation
=
(format code): Formats code
c/hello
changes everything until the first occurrence of hello.
ggyG
copies a whole document
gUw
capitalizes a word
yi(
: yanks everything within ( and so on…
d2w
: delete two words
d5j
: delete 5 lines downwards
df'
: to delete everything in the current line from the cursor until the first occurrence of the '
character, INCLUDING the character itself
dt'
: to delete everything in the current line from the cursor until the first occurrence of the '
character, EXCLUDING the character itself
d/hello
: to delete everything until the first occurrence of hello
ggdG
: to delete a complete document
{operator}{a|i}{text-object}
a
: around
i
: inner
w
for word
s
for sentence
'
, "
, ``` for quotes
p
for paragraph
b
or (, )
for block surrounded by ()
,
B or
{,
}for block surrounded by
{}`
<, >
for a block surrounded by <>
[, ]
for a block surrounded by []
t
for tag.
D
deletes from the cursor to the end of a line
daw
to delete a word (plus trailing whitespace)
ciw
to change inner word
das
to delete a sentence (dis
to delete inner sentence)
da"
to delete something in double quotes including the quotes themselves (di"
deletes only the content inside the quotes and spares the quotes)
ci"
to change something inside double quotes
dap
to delete a paragraph
dab
da(
or da)
to delete a block surrounded by (
daB
da{
or da}
to delete a block surrounded by {
dat
to delete an HTML tag
cit
to change the contents of an HTML tag
x
is equivalent to dl
and deletes the character under the cursor
X
is equivalent to dh
and deletes the character before the cursor
s
is equivalent to ch
, deletes the character under the cursor and puts you into Insert mode
~
to switch case for a single character
cc
changes a complete line
C
changes from the cursor until the end on the lin
i
: for insert and,
a
: for append.
I
: puts you in Insert mode at the beginning of the current line whilst,
A
: puts you in Insert mode at the end.
o
: inserts a new line below the current one and drops you into Insert mode (mnemonic open a line below)
O
: inserts a new line above the current one and also drops you into Insert mode
gi
: puts you into Insert mode at the last place you made a change. This is great if you drop from Insert mode by mistake and want to go back where you were and continue typing. (This behavior is slightly different to Vim where gi sends you to the last place you left Insert mode).
CTRL-h
: lets you delete the last character you typed
CTRL-w
: lets you delete the last word you typed
CTRL-u
: lets you delete the last line you typed
v
for visual mode character-wise. This mode lets you select text character by character
V
for visual mode line-wise. This other one lets you select text line by line
<C-V>
for visual mode block-wise. This last mode lets you select text using rectangular blocks
v{motion}{operator}
lvtbd
jVjjd
<C-V>8jc<li><ESC>C-V8j$A</li>
gn
-
- If you are on top of a search match, it selects the match in Visual mode.
- If you are in Visual mode, it extends your current selection until the end of the next match.
- (and the best part) If you are in Operator-pending mode, it operates on the next match.
gn
- there’s no need to combinen
and.
because.
already includes the next match.
/cucumber<ENTER>dgn4.
/(cucumber | cucumber)<ENTER>dgn4.
yl
- copy character
yy
- copy line
yy{count}p
- duplicates line n-times
yyp
- DUPLICATES line
yyP
- duplicate line ABOVE
ddp
& ddP
- SWAP lines
yi"P
- copy inside "
yi(P
- copy inside (
:reg
"
: unnamed register
a-z
: named registers
0
: yank register
1-9
: cut registers
CTRL-R "
pastes the contents of the unnamed register
CTRL-R a
pastes the contents of register a
CTRL-R 0
pastes the contents of the yank register
:.,$d
- to delete from the current line to the end of the file
:0,+10d
- to delete the first 10 lines
:.,+2d
- to delete the current line and the next two ones
:10,12d
- to delete lines 10, 11 and 12
@
: - you will repeat the last ex command, from then on you can repeat it again with @@
@@
- repeat it again
:[range]s/{pattern}/{substitute}/{flags}
:s/led/gold
- transmutes the first occurrence of led
in the current line into gold
.
:s/led/gold/g
- all occurrences in the current line
:%s/led/gold/g
- all occurrences for a whole file
/gi
- case insensitive
ds
to delete the surroundings
cs
to change the surroundings
ys
to add surroundings
ds{count}{motion}
cs{count}{motion}
ys{count}{motion}
ds'
to delete the surrounding '
(ds{char}
)
cs'"
to change the surrounding '
for "
(cs{old}{new}
)
ysaptli>
to surround a paragraph with an <li>
tag (ys{motion}{char}
)