Home arrow Site Administration arrow Page 6 - Vi 201

First Aid 101 - 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.

TABLE OF CONTENTS:
  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
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Unlike some of its better-known brethren, vi comes with some powerful crash recovery features. For example, let's suppose you're editing a file named "cart.php3", and your system suddenly crashes because Joe in the other room mistook the server's power button for the microwave's on/off switch.

Hey, some people are just born stupid-after all, only a moron would keep the microwave next to the server!

Well, once you get the system back up, recovering your file is as simple as typing

vi -r cart.php3
For every file that you edit, vi creates a temporary swap file by the same name and the file extension .swp in the same directory. When you add the -r parameter to the file name, vi will attempt to "recover" the file by reading the temporary backup and combining it with bits of the original file to get you back to where you were before the crash.

The temporary swap file is usually updated every four seconds or every 200 characters - although you can change this with the "updatetime" and "updatecount" commands.

Once you've confirmed that the restored version of the file is acceptable, you should delete the swap file to avoid error messages.

In addition to swap files, another very important file is the vi configuration file, usually found lurking in your home directory under the name ~/.vimrc . This configuration file is read every time you start the editor, and the commands and options in it executed automatically.

All the "colon" commands you've learnt thus far can be placed in the configuration file for automatic execution. There's one simple rule of thumb - if you execute the command while the editor is running, you usually need to precede it with a colon [as in the examples above]; however, the same command, when placed in the configuration file, will *not* be preceded by a colon. So, for example, though I might type

:abbreviate god Professor Elias Flootburger The Third
in the editor, my configuration file would only contain

abbreviate god Professor Elias Flootburger The Third
without the initial colon [:]

A simple way to create your .vimrc configuration file is to set the editor up the way you want, and then execute the command

:mkvimrc
which will create a configuration file for you automatically. And also take a look at Sven Guckes' heavily commented configuration file at http://www.math.fu-berlin.de/~guckes/vim/vimrc.forall for more information on the various options.

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
   

SITE ADMINISTRATION ARTICLES

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