Home arrow Site Administration arrow Page 2 - Vi 201

Liar, Liar... - Administration

In his last class, he taught you the basics of vi, the powerful *NIX text editor. Now Elias Flootburger returns in this hilarious sequel to theoriginal "Vi 101" tutorial. This time, the good professor has his handsfull with abbreviations, key mappings, autocommands and vi's powerfulvisual mode...not to mention his own out-of-control ego!Note: Most of the material in this article covers vim, the enhanced version of vi that is preinstalled on most modern *NIXes.

  1. Vi 201
  2. Liar, Liar...
  3. Re-thinking Relativity
  4. Sweet Revenge
  5. The Shell Game
  6. First Aid 101
  7. An Indent In Time...
  8. Exit Flootburger
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 4
May 11, 2000

print this article


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

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

to delete your entire selection, or

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

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

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

If you're a programmer,


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

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

to repeat the previous selection.

To exit visual mode, simply tap the

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

or a

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