Home arrow Site Administration arrow Page 3 - Vi 101

Start Me Up! - Administration

Vi is probably the most powerful text editor for *NIX, but if you have ever tried to use it, you probably walked away frustrated. This article walks through all the capabilities and features of Vi - from the basics, such as saving and quitting, to the more advanced topics of searching for strings.

  1. Vi 101
  2. Vi? V who?
  3. Start Me Up!
  4. Let's Tango!
  5. Lather, Rinse, Repeat...
  6. One, Two, Buckle My Shoe...
  7. Searching For Hope
  8. Of Files And Windows
  9. Saved By The Bell
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 5
March 27, 2000

print this article



Starting a vi session is ridiculously simple; type

$ vi
at your UNIX shell prompt, followed by a carriage return, and vi will pop open an empty file for you to begin work. Alternatively, you could specify the file to open on the command line itself, like this:

$ vi myfile
Don't worry about the ~ signs in the editor - they're simply visual indicators of the bottom of your file, and don't actually appear in your document.

The first - and most confusing thing - about vi is the various different modes the editor can operate in. For our purposes, I'll split them into two broad categories: "insert mode", and "command mode". "Insert mode" is where you'll be spending most of your time - it allows you to add, or insert, text into your document. "Command mode," on the other hand, lets you move around the document, delete or replace blocks of text, and access useful vi functions like buffers and ranges.

When vi first starts up, it's usually in command mode. To enter insert mode, type

vi will display a visual notification of the mode change in the bottom left corner. You can now enter text into the document in the normal manner; when you're done, hit

to return to command mode.

To begin inserting text on a new line, try

to enter insert mode with the cursor already positioned on the next line, or

to enter it with the cursor on the previous line.

In addition to inserting text, vi also allows you to overwrite existing text - this is known as "replace mode", and can be entered by typing

from command mode. Everything you type will now "write over" existing text. If your intention was to replace a single character - for example, correcting a spelling error - use

to replace only a single character; the editor will automatically return you to command mode after the character has been replaced.

Obviously, at some point, you're going to need to save your work. In vi, this is accomplished via the "write" command, abbreviated to

To quit, use the handy "quit" command, known to family and friends as

vi also lets you combine frequently-used commands together - to really impress the pretty girls, not to mention add a few points to your geek quotient, try

for powerful save-and-exit functionality. Alternatively, if you've decided to bury whatever you've just written, try

which exits vi without saving any changes to the file being edited.

Obviously, all these "colon" commands need to be executed in command mode - attempting them while in insert mode will result in them appearing as part of your document, and no professor likes to receive assignments interspersed with :wqs and :q!s. Well, actually, some of them do - but that's mostly the younger crowd, and what can you expect from them? Those punks actually think rock 'n' roll is dead...

This article copyright Melonfire 2000. All rights reserved.

>>> More Site Administration Articles          >>> More By Vikram Vaswani, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Coding: Not Just for Developers
- To Support or Not Support IE?
- Administration: Networking OSX and Win 7
- DotNetNuke Gets Social
- Integrating MailChimp with Joomla: Creating ...
- Integrating MailChimp with Joomla: List Mana...
- Integrating MailChimp with Joomla: Building ...
- Integrating MailChimp with Joomla
- More Top WordPress Plugins for Social Media
- Optimizing Security: SSH Public Key Authenti...
- Patches and Rejects in Software Configuratio...
- Configuring a CVS Server
- Managing Code and Teams for Cross-Platform S...
- Software Configuration Management
- Back Up a Joomla Site with Akeeba Backup

Developer Shed Affiliates


Dev Shed Tutorial Topics: