A 'vi' question: the answer
Lloyd Zusman
ljz at fxgrp.UUCP
Tue Jun 14 07:31:11 AEST 1988
The other day I posed a question about 'vi': what is the syntax of the
commands you can embed near the top of your file which can be used
to set tab stops?
I got several prompt replies, for which I am grateful. Thanks to all
of you.
Here's how to do what I asked:
The commands can reside anywhere in the first or last 5 lines of the
file that is being edited. They are of the form
<W>ex:<commands>:
or
<W>vi:<commands>:
where "<W>" is one or more whitespace (space or tab) and "<commands>"
are any commands you can issue from the ":" prompt. For example, to
set the tab stops to 13 characters, you could put the following stuff
within 5 lines of the top or bottom of your file:
<TAB>ex:set tabstop=13 shiftwidth=13:
(the 'shiftwidth' is there so that the "<<", ">>", and other shifting
commands will properly shift the text to a tab stop).
Of course, these lines should probably be contained within comments.
In many recent versions of 'vi', you must also set the 'modeline'
variable in order to enable the execution of these embedded commands.
I found that this only works by putting the following command into
.exrc or your EXINIT variable:
set modeline
(I couldn't get "vi '+set modeline' file" to work after not trying all
that hard). In these recent versions of 'vi', the default is 'set
nomodeline'.
Keep in mind that you can theoretically execute any commands that are
legal at the ":" prompt, not just tab setting commands.
Thanks again for all the quick replies.
--
Lloyd Zusman UUCP: ...!ames!fxgrp!ljz
Master Byte Software Internet: ljz%fx.com at ames.arc.nasa.gov
Los Gatos, California or try: fxgrp!ljz at ames.arc.nasa.gov
"We take things well in hand."
More information about the Comp.unix.questions
mailing list