Skip to content

Instantly share code, notes, and snippets.

@abhi5658
Last active January 10, 2022 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhi5658/e5a63a8877a9972f341ecbedd5d8d0df to your computer and use it in GitHub Desktop.
Save abhi5658/e5a63a8877a9972f341ecbedd5d8d0df to your computer and use it in GitHub Desktop.
My log of learning vim commands

https://cyber.wizard.institute/


press i to get into --INSERT-- mode
press 'escape' to return to command mode
press a to place insert after the cursor

:w - saves a file
:w <filename.ext> - to save with a new filename
:q - quits the editor
:wq - combine the commands

testwekn wdkfnf odwn ncjdsknks
sdlkdskvnvkv
sdskj nsd
sdfdsfhknkkm

h - move left
j - move down
k - move up
l - move right

0 or ^ - beginning of line
$ - end of line

gg - goto start of first line
G - goto start of last line
x - delete single character under the cursor/before the cursor
dd - delete a line
d$ - deletes from cursor to the end of line
d0 or d^ - deletes from cursor to the beginnging of the line
dgg - delete from cursor to start of file
dG - delete from cursor to end of file
dj - delete current and below line
dk - delete current and above line
dh - delete single character before the cursor (similar to x)
dl - delete single character after the cursor
2dd, 3dd - delete the next N lines

/PATTERN - jump to next match of PATTERN
?PATTERN - search bacckwards to find PATTERN
n - next match (down)
N - previous match (up)
d/PATTERN - delete till the first match of PATTERN (excluding the pattern)
d?PATTERN - ...
dn / dN - ...

fX - search ahead for X on the same line
FX - search back for X on the same line

:s/PATTERN/REPLACEMENT/FLAGS - :s/cat/dog/i or :s/cat/dog/ig
i - case insensitive
g - global
:%s/cat/dog/ig - replace cat with dog in entire file


press v to enter visual select mode
move around to select text
y - yank the text into paste buffer
x or d - delete the selected text
>> - indent the text right by shiftwidth
<< - indent the text left by shiftwidth
p - paste yanked/deleted content which is present in buffer

v - visual select by characters
V - visual select by lines
ctrl+v - select in a block




Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment