![]()
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
What is vi?For many people, vi (to be prononced as 2 separated lines) is a scary word... vi is actually a simple but powerful text editor that comes with all Unix systems. If this program seems to be so frightening it is because it is far from being user-friendly and intuitive, but it is *extremely* efficient and powerful. To start vi, just type ' Use, principleWhat makes vi so special is the way to use it. There is no menu or whatever, and any kind of interaction is actually a blind interaction (you rarely see what you are typing). vi uses to different modes to work: a insert mode to add text in the file, and a normal mode use to type vi commands and interact with the program (save the file...). The insert mode may be recognized by a "-- INSERT --" message at the bottom of the screen. When it this message does not appear, you are certainly in the normal mode. The most 2 important keys with vi are 'Escape' and 'i': we use the Escape key to leave the insert mode and enter the normal mode or to cancel a current action (we even strike this key 3 or 4 times to really be sure we are in the normal mode), thought we use the 'i' key to enter the insert mode. The key to vi is to know how to use its commands. All interesting actions are performed outside of the insert mode. The basic thing to know before going furter is to know how to go from one mode to another. Useful commandsThese commands are executed in the normal mode. Just strike a couple of times the Escape key to enter this mode. Most relevant commands are short (just one key or CTRL-key for instance), and in this case keys are enough. However, some commands are long (for instance, when we want to save a file, we may need to specify its name), and then we have to type a ":" before going further. In this latter case, the complete command is displayed at the bottom of the screen. Standard commands
How to move aroundThe Linux version of vi supports the arrow key to move around at any moment. However on many Unix systems, moves can be performed only in the normal mode and with the following keys (these keys are also available with Linux):
Some other keys may be used to move faster in the file:
It is possible to combine the letters w, b and e with numbers (to be specified before, like 34w for instance) to jump the given number of words in the specified direction. Insert/delete charactersThis table gathers some useful keys used to delete or insert words:
Search
Substitutionsvi supports commands that can be used to handle regular expressions. The programmed character substitution is one of those. Let's have an example. Let's suppose we want to replace the word "foo" by "bar". The standard command is:
This will make a change only on the first occurrence on the current line. To make a change on every occurrence of the current line, on uses:
Fianlly, if we want to change all occurrences of the file, we do:
The '%' symbol means "for every line"; one must put a 'g' at the end of the command to make the substitution happens completely on every line. MiscellaneousThis table gathers some intersting commands that cannot be classified in the previous sections:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Copyright © 2000-2002 themanualpage.org - This site is submissive to the terms of the GNU GPL and FDL licences. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||