If you know nothing about vim, you can also read this and feel the power.
Remember, there is a tutor at your service anytime in your terminal. Just summon the tutor with vimtutor
. What? You haven't install vim? Never mind.
The first thing you need to know about vim is HOW TO QUIT
quit
:q!
quit a vim editor without saving
If you are using VSCode extension Vim, you don't need to "quit" ;)
aCharacter
should be replaced with character you want
aString
should be replaced with string you want
motion
j
/ k
/ h
/ l
down, up, left, right
I think j
is down because usually we read a file from top to bottom
so we can press j
with index finger
gg
/ G
move to start / end of this file
0
/ $
move to start / end of this line
^
move to first character of this line
ctrl + o
/ ctrl + i
move cursor to previous / next position
#
/ *
move cursor to previous / next occurrence of current word under cursor
ctrl + w
switch between panels
ctrl + b
/ ctrl + f
move backward / forward a page
In VSCode: If you check fold fix, this might not work
ctrl + u
/ ctrl + d
move up / down half page
In VSCode: If you check fold fix, this might not work
editing
ciw
change in word
diw
delete in word
d
/ c
/ y
+ i
+ ({["'
delete / change / yank in ()
{}
[]
""
''
and etc
you will love this
dt aCharacter
delete to aCharacter
>>
/ <<
increase / decrease indentation
A
append to the end of this line
I
insert at the start of this line
J
join current line with next line
r + enter
replace character under cursor with enter
D
delete to the end of this line
dd
delete this line
~
toggle letter case
.
repeat last text change
u
/ ctrl + r
undo / redo
In VSCode: this might be unreliable, enter insert mode and use ctrl + z
for the rescue
function
za
toggle folding
In VSCode: If you ran into trouble with motion, ctrl + ,
open settings, search vim fold
, check fold fix.
:%s/foo/bar/g
%
in all lines s
substitute foo with bar g
every occurrence in corresponding line
/ aString
search aString
press enter
move cursor to the occurrence of aString
press n
move cursor to next occurrence of aString
press N
move cursor to previous occurrence of aString
ctrl + ,
open settings, search vim clip
, check use system clipboard to use system clipboard
ctrl + ,
open settings, search vim easy
, check enable easymotion plugin, now you can use \\
with hjkl
Top comments (0)