Home arrow Programming Fundamentals arrow Learning vi Modes

Language Translator

Hacking Zone

Hacking Tools
Attacking

Configure Windows

Windows Configuration

Mix Tutorials

Asterisk
Website Building

Novels

Mix Novels

Human Personality

Body Language
Learning vi Modes Print E-mail
Article Index
Learning vi Modes
Page 2
Page 3

vim Editor Tutorial


Emacs may show its age, but before there was an emacs, vi was the best thing around. The fact that vi is still here, and still being used, shows that it, like shells and shell scripts, still serves a purpose for many users. Vi, short for visual editor, is a modal editor. In vi, there are two modes: insert and command. In insert mode, the text you type gets entered into the file you are editing. In command mode, the keys you type are interpreted as vi commands, short cryptic commands that can have a major effect on your

To start vi, simply enter the vi command:

$ vi

You can also start vi with a session editing a particular file. For example:

$ vi script1

This command tells vi to edit a file named script1 in the current directory. Vi can create the file if it does not exist.

You can pass more than one file name on the command line. For example:

$ vi script1 script2 script3

Vi shows each file one at a time. The :n command (see the second table following) jumps to the next file.

When you start vi, the editor places you in command mode. Thus, any keys you start typing are assumed to be commands. Unlike emacs, you cannot just start typing text. Instead, you have to enter a command to switch to insert mode. The most common command to enter insert mode is a lowercase i, short for insert.

The following table lists the commands to switch over to insert mode.

Vi Insert Command Purpose

i Inserts before the current character

I Inserts at the beginning of the line

a Appends after (to the right of) the current character

A Appends at the end of the current line

o Inserts a new line after the current line

O Inserts a new line before the current line

Once in insert mode, the text you type gets entered into the file you are editing. Press Esc to exit insert mode.

Some versions of vi display text at the bottom of the editor telling you that you are in insert mode, such as the following:

-- INSERT --

But many versions of vi provide no feedback as to which mode you are in. If you&rsquore ever unsure, just press Esc twice. If you are already in command mode, vi merely beeps at you. When you get into command mode, vi beeps at you.

One of the best descriptions of vi is that it is a program that beeps at you a lot.



 
< Prev   Next >
Your Ad Here

Donate us!!

Enter Amount:

RSS socialnet

Add to MyYahoo!
Subscribe in NewsGator Online
Add to Newsburst
Add to Google
Add to My AOL
Add to Pluck
Subscribe in FeedLounge
Add to Windows Live
Add to NetVibes
Subscribe in Rojo
Subscribe in Bloglines
Add to MyMSN
Add to Plusmo for your cellphone
Add to PageFlakes
Add to Technorati
Add to BlinkBits