vim tips part 1.

Yes, A little bit of googling will give you good results but this is like most of all I have here: meant to be for beginners. so here goes.

Note my conventions
:w means type the phrase :w in normal mode (not insert mode)
`a` means hit the a key in normal mode

Tip #1 – Are you really using vim?
First off, you need to figure out if you’re using VI or VIM.
No  they are not the same and are not intended to be.
I believe ubuntu ships with vi and not vim so you do not get vim out of the box.
Some distros alias `vi` to `vim` but trust me, you will want to get used to typing `vim` not `vi`
This way you’re always sure you’re using vim and not vi

Tip #2 – Cursor Navigation
:1 takes you to the first line
:122 takes you to the 122nd line
:$ take you to the last line
`a` moves the cursor one character forward and enables INSERT
`i` does not move the cursor, it sets the cursor to INSERT wherever it is.
`o` moves the cursor one line down and enables INSERT

Tip #3 – File / Edit Management
`u` undoes your last action
:w saves the file
:q quits whatever you’re doing provided there’s no change to the file
:wq saves the file and then exits
:q! quits vim without saving
Do Not make it a habbit of hitting :wq!
This forces a save without a warning if there’s supposed to be one.

So thats it for the ultimate basics. Get used to this, more to come.

label, , ,

About the author

Add a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.