Home arrow Site Administration arrow Page 5 - Vi 201

The Shell Game - 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
The guys who created vi built in all kinds of creature comforts designed to reduce your interaction with the shell to a minimum. One of the coolest ideas they came up with was a "shell filter", which allows you to replace shell commands with their output without needing to leave the editor at all.

Try this - open up a blank document and type

Today's date is date
Now exit insert mode, position the cursor over the second "date" in that line, and type

!!bash
The line should now read

Today's date is Tue May 2 15:54:13 IST 2000
or whatever the current date and time happens to be on your system. Vi passes the word under the cursor to the interpreter specified by the user - the "bash" shell, in this case - as a command, and then replaces the word with the output of that command.

Despite these time-saving features, there are times when you'll want to execute a shell command directly. In vi, you can do this with

:! <shell-command>
So, if you needed a quick directory listing of the /home directory, you could type

:! ls -l /home
and vi would pass the command to the shell, and display the output to you.

Finally, vi also allows you to spawn a new shell with the

:shell
command. You can then execute shell commands and run other programs - even a new instance of vi, although only the truly warped among you would find this entertaining.

Once you're done, simply log out of the spawned shell by typing

^-D
and you'll be returned to your original vi session.

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: