Ultra quick start in Vim

Vim is a very powerful text editor. It is also quite an intimidating text editor to those that haven't used it before and if you're interested in just getting started with Vim and learning how to use it as a basic text editor, it can be quite daunting.

What I am going to attempt to give you today is an ultra quick start guide to editing files in Vim. Let me reiterate that - I'm going to go over the most basic concepts really quickly. There is plenty more that Vim can do and this is only really designed to whet your appetite for the editor.

So, let's begin. You can open Vim by typing vim and then a filename at your command line. That filename can be a file that already exists, or a new file you want to create.

$ vim newfile

Once you hit enter, the command line goes away and you enter the Vim interface. Vim has a concept of different modes for editing, which means in order to do some tasks you might need to be in a certain mode. The two modes we need to worry about here are Normal mode and Insert mode.

By default, you start in normal mode. In most modern versions of Vim, you should be able to browse the document if it exists with the arrow keys (or use Ctrl-D to scroll down more quickly).

To insert, or edit text, we need to switch from Normal mode into Insert mode. You do that by pressing the letter i. You should see this near the bottom of the screen:

-- INSERT --

Now, you can use the keyboard as you would normally to type text into the document. Once you're done making the edit and want to switch back to Normal mode, press Esc.

The INSERT message at the bottom should go away, and anything you type will be interpreted as a command, not as text to type into the document.

That is basically the bare minimum you need to know to get started editing in Vim, or if you just want to use it quickly. However, it would also be quite useful to know how to save and quit the editor.

While in Normal mode (remember - Esc will get you back to it at any time), typing these commands in and pressing Enter will do the following:

:w - save the file (the 'w' stands for write).
:q - quit the file. If you haven't saved the file since you last changed it, you will be warned and it will not quit. If you want to delete the changes...
:q! - quit the file, not saving your changes.
:wq - save and quit the file in one fell swoop!

I'm going to say this yet again - this is only scratching the surface of what Vim can do, but if you want to get up and running and editing files in it, this is the bare minimum of the knowledge you need!

Avatar for peter Peter Upfold - http://peter.upfold.org.uk/

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

Home » Articles »

Discussion: Ultra quick start in Vim

  1. earpick (guest)

    # Posted on 03 March 2008 at 10:51 PM

    Much appreciated. Just the kind of quickstart guide I needed =)



  2. Abhisek (guest)

    # Posted on 19 March 2008 at 05:05 PM

    There are many other shortcuts and tricks in VIM. An inbuilt tutorial is also available with the command "vimtutor"



Home » Articles » Ultra quick start in Vim