Sep 122012
 

Vi is an old screen-oriented text editor , the first release of this software is dated back in 1976, originally created for the Unix operating system.
What I like of vi is that I can find it in any Linux and Unix system I’ve to work, so once I learnt how to use it I’ve used it everywhere, but there is small problem the software is user-friendly as could be a software wrote in 1976, so many new users find really hard to understand the shortcuts and so after some small test they decide that the software is too hard and return to some graphical editor like gedit, leafpad or perhaps libreoffice.

With this article I want to give some useful information for people who have never used Vi.

Note: in general I use Vim (V IMproved) on all my systems, so I’m sure that all the following tips work with this software, if you use the classic VI some of the tips could not work.


Step 1 The base.

If you don’t know the shortcuts of vi and you want to spend some time with an online game i suggest to learn the basic of vi on http://vim-adventures.com/

VIM Adventures is an online game based on VIM’s keyboard shortcuts (commands, motions and operators). It’s the “Zelda meets text editing” game. It’s a puzzle game for practicing and memorizing VIM commands (good old VI is also covered, of course). It’s an easy way to learn VIM without a steep learning curve.
You play a blinking cursor appearing one day in a semi text based world inhabited by little people but ruled by bugs. You soon discover that your arrival was foretold by an old prophecy and that you’re expected to restore order to the world.

Step 2 The base part 2

Ok, i can understand that perhaps learning Vi shortcuts in a flash game may not be suitable for all, or perhaps you think that this is not a kind of study your Boss will likes, so the following is the list of some more traditional guides and tutorial on vi:

Vi turorial for Beginners
Beginner’s guide to Vi Improved (vim)

And if you prefer something more interactive (no game this time):

Interactive Vim tutorial

Step 3 The Cheat sheet

At this point you should know some of the shortcuts available in vi, and you could start to think “How will I remember all of these commands ?”, don’t worry anymore there is a nice graphical cheat sheet available (in colors !) that you can print and keep next to your keyboard, you can find it in the website: http://www.viemu.com

There you can find a single page describing the full vi/vim input model, the function of all keys, and all major features. You can see it as a compressed vi/vim manual.

Step 4 Get the full control of your vimrc file

Vim’s settings are stored in a configuration file called .vimrc which is located in your profile’s home directory. You can add dozens of excellent features to Vim by making some very simple changes in this file – only one problem, you have to do a lot of reading to figure out which settings to enable, but I’m here for this 😉 these are some useful settings that i use in my .vimrc:

set modeline
set statusline=%F%m%r%h%w\ [\%03.3b]\ [\%02.2B]\ [%04l,%04v][%p%%]\ [%L]

The statusline at the bottom of the window is handy little tool to show all kinds of information about the file and the character where the cursor is located.
This shows, from left to right:

  • file name
  • is the file modified or not flag
  • readonly flag
  • flag for indicating if the window is for help
  • same for preview
  • value of the char under cursor in decimal
  • same in hexadecimal
  • line number where the cursor is
  • and virtual column number
  • cursor position in buffer in percentage
  • number of lines in the buffer

syntax on
Enable syntax highlighting

set number
Display line numbers on the left

set showmatch

This will highlight matching parens, some people dislike this option that it’s become a defualt in some Distributions, if you want to disable this feature you can use set noshowmatch .

And these are some useful links to get more .vimrc information and examples:

The ultimate vimrc configuration file for vim text editor
The perfect .vimrc vim config file
My .vimrc tips and tricks


And the dedicated blog:
VI Improved Tips :: vimrc dissected

Popular Posts:

Flattr this!

  6 Responses to “Vi : Guides for Beginners”

  1. perche’ si paragonano sempre gli estremi? da VI agli aditor grafici ? e in mezzo? io trovo comodissimo usare midnight commander, pure lui un software vecchissimo di unix, cosi’ giro per il filesysteme e se voglio editare un file premo F4, edito F2 e ho fatto. Il resto sono pugnette.

  2. Before you begin this tutorial series. Can you please make an article to convince why one should invest time in learning VI?
    May be, and this is just an hypothesis, should I better spend my time working toward winning a Nobel Prize in physics rather than trying to learn VI?

    • If for you these 2 things require the same time, i agree..go for the Nobel 😉
      If you are a system administrator that has to work on Linux server, vi is a tool that you are sure to find.

      Best regards

  3. Before you begin this tutorial series. Can you please make an article to convince why one should invest time in learning VI?

    Didn’t he do this in the second sentence? Here:

    What I like of vi is that I can find it in any Linux and Unix system I’ve to work, so once I learnt how to use it I’ve used it everywhere

    Another plus is that you don’t need a mouse to use it efficiently.

    May be, and this is just an hypothesis, should I better spend my time working toward winning a Nobel Prize in physics rather than trying to learn VI?

    You are not very serious. Anyway, you can’t predict that you’ll get the Nobel Prize in physics, but you can be quite sure that you’ll improve in vi over time. And as any other great tool it may help you getting that Nobel Prize …

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*