vim filename
:wq
-> save and quit:q
-> quit and not save:w
-> save and not quit:number
will take you to line numberh j k l
to move up down left and rightHitting āiā in command mode lets you insert
Hitting shift + i will set insert mode at the beginning of the line
Then esc puts you back into command mode
Hitting dd will delete a line and copy to clip board
Hitting d + } will delete a whole block of code
Hitting 10 dd will delete 10 lines
Hitting u
will undo
Hitting ctrl + r will redo
Hitting yy will copy a line
p to paste bellow P to paste above
x remove a letter where the cursor is
number x remove number letters before cursor
~ swap the case of the letter prefix with number for multiple characters
. redo
$ will take you to the end of a line
W will jump spaces and B reverses that
f + char find and place cursor on char
t + charfind and place cursor before char
% take you to and from closing brackets
d + % remove code between brackets
c + w change mode and word will remove a word and set insert mode
D remove everthing from cursor onwards
c + t + char edit from cursor to char
C change whole line
d + t + char delete from cursor to char
* take you to occurances of the word where your cursor is
; take you to next instance after using a find command
r + char replace letter at cursor with char prefix with number for multiple replaces
R allow to replace lots of letters into replace mode
@
with a number to replace that many timesctrl + v enter visual block mode. Now you can select columns and hit r
to replace things.
In visual block mode hitting shift i will allow you to type and then after you hit esc the text will appear in all places selected
NOTES EXTRA:
gd
to jump to definition of whatever is under your cursor.gf
to jump to a file in an import.{line}gg
to go to a specific line.{operator}{count}{motion}
{count}{operator}{motion}
For instance, the d2w
combination allows you to delete two words
c/hello
changes everything until the first occurrence of hello
.ggyG
copies a whole documentgUw
capitalizes a worddaw
to delete a word (plus trailing whitespace)ciw
to change inner worddas
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 quotesdap
to delete a paragraphdab
da(
or da)
to delete a block surrounded by (
daB
da{
or da}
to delete a block surrounded by {
dat
to delete an HTML tagcit
to change the contents of an HTML tag