Administration
  Home arrow Administration arrow Page 3 - Vi 101
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ADMINISTRATION

Vi 101
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 5
    2000-03-27

    Table of Contents:
  • Vi 101
  • Vi? V who?
  • Start Me Up!
  • Let's Tango!
  • Lather, Rinse, Repeat...
  • One, Two, Buckle My Shoe...
  • Searching For Hope
  • Of Files And Windows
  • Saved By The Bell

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Vi 101 - Start Me Up!


    (Page 3 of 9 )


    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

    i
    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

    <ESC>
    to return to command mode.

    To begin inserting text on a new line, try

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

    O
    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

    R
    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

    r
    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

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

    :q
    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

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

    :q!
    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 Administration Articles
    More By Vikram Vaswani, (c) Melonfire


     

       

    ADMINISTRATION ARTICLES

    - Network Administration with FreeBSD 7
    - Components of an Information Architecture
    - The Anatomy of an Information Architecture
    - Configuring Load-Balanced Clusters
    - Load-Balanced Clusters
    - UNIX Time Format Demystified
    - Making Changes in the CVS
    - Building Your First CVS Repository
    - CVS Quickstart Guide
    - Authorizing Users in Samba
    - Handling User Accounts in Samba
    - Authentication in Samba
    - Accounts, Authentication, and Authorization
    - Advanced Concepts on Dealing with Files and ...
    - Dealing with Files and Filesystems





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway