Administration
  Home arrow Administration arrow Page 2 - Vi 201
Dev Shed Forums 
Administration  
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 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
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 201
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2000-05-11

    Table of Contents:
  • Vi 201
  • Liar, Liar...
  • Re-thinking Relativity
  • Sweet Revenge
  • The Shell Game
  • First Aid 101
  • An Indent In Time...
  • Exit Flootburger

  • 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

    PCmover - $15 Off with Coupon Code CJPH7Q

    Vi 201 - Liar, Liar...
    (Page 2 of 8 )

    The last time we met, I told you that vi operates in either one of two modes - "command mode" and "insert mode".

    Well, I lied.

    Don't look so horrified - I hate to burst your bubble, but people lie all the time. And just so you know - Santa Claus doesn't exist, and the tooth fairy decided to get out of the business a few years ago; she's now in Las Vegas earning millions as a showgirl...

    Anyway, getting back to vi - the editor also comes with a very powerful "visual mode", which allows you to select blocks of text and perform actions - cutting, copying, deleting - on them, in a manner similar to Windows-based editors like Microsoft Word.

    Entering visual mode is simplicity itself - simply hit

    v
    while in command mode. Vi will display a visual notification of the mode change at the bottom left corner of your screen. Now try using the various motion keys to move around - you'll notice that instead of moving you around the document, those keys now control a selection block which can be used to highlight sections of the text.

    In addition to visual mode, there's also a "visual line" mode, which allows you to perform line-by-line selection and is activated by hitting

    V [that's Shift-V]
    and a "visual block" mode, which allows you to select vertical, rather than horizontal, blocks of text - hit

    ^-V [that's Ctrl-V]
    to activate this mode. In all these different visual modes, the usual motion keys can be used to control the size of the selection block.

    Now that you've got your text selected, it's time to do something with it - and vi comes with some built-in actions that allow you to interact with your selection. For example, type

    d
    to delete your entire selection, or

    y
    to copy it. You can then paste it by moving to the appropriate point in your document and hitting

    p
    The "change" command, activated in visual mode by typing

    c
    will delete the selected block and enter insert mode at the first character position of the deleted block.

    If you're a programmer,

    <
    and

    >
    can be used to indent blocks of code left and right, respectively. And

    ~
    can be used to switch the case of the selected text, from upper-case to lower-case and vice-versa.

    A couple of other interesting commands in visual mode - type

    o
    to move the cursor between the upper left corner and lower right corner of your selection block, or

    gv
    to repeat the previous selection.

    To exit visual mode, simply tap the

    <ESC>
    key, and you'll be returned to command mode.

    As you'll see after you play with it for a while, visual mode is extremely powerful. It comes in particularly handy when you're dealing with large text files, and need to transpose sections of text from one place to another - instead of counting the number of lines to be copied, and then doing a

    10dd
    or a

    21yy
    you can simply select the lines of text with the motion keys, and use the operators above to transfer them to their new home. With power like this, who needs Santa Claus?

    This article copyright Melonfire 2000. All rights reserved.

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


     

       

    ADMINISTRATION ARTICLES

    - 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
    - More Hacks for the User Environment in BSD
    - Personalizing the User Environment in BSD
    - Customizing the User Environment in BSD




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