|
The editor can be initialized by the shell variable EXINIT, which looks like:
EXINIT='<cmd>|<cmd>|...' <cmd>: set options map ... ab ... export EXINIT (in the Bourne shell)However, a better way is to put the list of initializations into a file. If this file is located in your home directory, and is named .exrc and the variable EXINIT is not set, the list will be executed automatically at startup time. However, vi will always execute the contents of a .exrc in the current directory, if you own the file. Otherwise you have to type
:so fileto source the file yourself. In a .exrc file a comment is introduced with a double quote character: the rest of the line is ignored.1 On-line initializations can be given with vi +<cmd> file, e.g.:
vi +x file | The cursor will immediately jump to line x | (default last line). vi +/<string> file | Jump to the first occurrence of <string>.You can start at a particular tag with:
vi -t <tag> | Start in the right file in the right place.Sometimes, e.g. if the system crashed while you were editing, it is possible to recover files lost in the editor by typing vi -r file. Typing vi -r shows the files you can recover. The readonly flag allows you to view a file with vi without the danger of accidentally saving changes. However, if you do make changes that you decide you want to save, typing :w! will override the readonly option.
This section is based on "Vi Reference" by Maarten Litmaath et al.
© 1993-2001 Christopher C. Taylor |
|||||||