All Articles

VIM Skills

Working from the command line you frequently need to view and edit files. VIM, or Vi Improved to give it its Sunday name is my editor of choice. Its very powerful, but no one could ever say its user friendly or easy to learn. It has a horrendous learning curve and is initially bafflingly unintuitive. Many a unwary user has been stuck in VIM purgatory trying to exit it.

for the record :q! <enter> is the key combination to exit

There is no more impressive sight in the geek world than a fully bearded sysop working in VIM. As is always the case with the CLI, it beats a GUI every time in the hands of a proficient user.

Trouble with VIM is that not many of use have those godlike skills. Every VIM user would probably say they know enough to get the job done, so its always handy to keep refreshing the typing muscle memory and reminding yourself of those keyboard commands that you’re vaguely aware of, but can never remember in the heat of battle.

From within VIM if you type :help you get access to a very comprehensive help file. Unfortunately VIM isn’t something that you can learn by reading.

Fortunately though, theres a little known gem installed alongside VIM (well little known by me anyway) to help you out. Typing vimtutor opens up an interactive tutorial which is a delight to work through.

I’m embarrassed to say I’ve been using VIM now for a few years and never knew how to undo a change, I would be exit without saving and go back in and re-edit!

I can’t emphasise enough how good this tutorial is. Theres really no excuses for not brushing up regularly on those VIM skills.

Below is a quick look at Lesson 1.1

** To move the cursor, press the h,j,k,l keys as indicated. **

Hint:  The h key is at the left and moves left.
The l key is at the right and moves right.
The j key looks like a down arrow.

1. Move the cursor around the screen until you are comfortable.

2. Hold down the down key (j) until it repeats.
     Now you know how to move to the next lesson.

3. Using the down key, move to Lesson 1.2.

NOTE: If you are ever unsure about something you typed, press <ESC> to place you in Normal mode.  Then retype the command you wanted.

NOTE: The cursor keys should also work.  But using hjkl you will be able to move around much faster, once you get used to it.  Really!
Published 11 Dec 2016

John McCracken