search by tags

for the user

adventures into the land of the command line

vim cheat sheet and the .vimrc file


h - left
j - up
k - down
l - right
^ - beginning of text on a line
$ - end of text on a line
0 - first position on line


y(ank) - copy
d(elete) - cut
c(hange) - replace
p(aste) - put from buffer after cursor
o(pen) - start a new line
i(nsert) - insert before current character
a(ppend) - insert after current character
w(ord) - moves to beginning of next word
b(ack) - moves to beginning of current word or prior word
e(nd) - moves to end of current word or next word
f(ind) - moves to a character on the current line

most commands can be prefaced with numeric modifiers.

2w - means move 2 words
5h - means move 5 characters to the left
3k - means move 3 lines up
3fs - means move to the 3rd letter s following the cursor

some other useful commands

delete char after cursor - x [enter]
undo - u
save and quit - :wq
quit - :q
quit without saving - :q!
end of document - shift+g
start of document - gg
search - /
remove highlighting - :nohl
set line numbers - :set number
hide line numbers - :set nonumber
paste without vim adding tabs - :set paste
:s/Search-Word/Replace-Word/gc - search and replace current line
:3,7s/Search-Word/Replace-Word/gc - search and replace lines 3-7
:%s/Search-Word/Replace-Word/gc - search and replace whole document
:%s/Search-Word/Replace-Word/gc - search and replace ask for comfirmation
:%s/Search-Word/Replace-Word/gi - search and replace case insensitive

sometimes, vim can seem stupid, like when in insert mode, the arrow keys and the backspace key actually type characters, rather than moving the cursor around. you find yourself having to constantly switch between insert and view mode… this is lame

thankfully, vim can be customised to behave more intuitively, by way of a config file called .vimrc (or .virc, if you use vi), which goes in your user’s home directory. you can create one

$ vim ~/.vimrc

here’s a really great example vim configuration i came across at