vi '_' command
chris at umcp-cs.UUCP
chris at umcp-cs.UUCP
Mon Mar 19 17:27:54 AEST 1984
As long as we're pointing out things in vi, here's some info that
may be of interest to people.
The '_' command is very similar to the '^' command in that it moves
to the first nonblank character of the current line. The key
difference is that '_' is a *line* command while '^' is a *character*
command. This is important for all functions that read an "address",
for example, "d", "y", "c".
In fact "d"(elete), "y"(ank), etc, all call a common internal
routine in vi to get an "address". If the address is of a particular
character, then a character-mode delete/yank/whatever is done. If
it is a line address, a line mode operation is performed. The
"address" command may be any of the regular positioning commands
(e.g. W b $ /pattern/) or the original character repeated (as in
dd or yy).
Some examples:
You type VI does
-------- -------
dd Deletes the current line.
d'a Deletes all lines between the current line and the
line containing mark "a", inclusive.
d`a Deletes all characters between the current character
and the character at mark "a". This works much
like an Emacs ^W in that the two endpoints are
considered to be between two characters. Note that
a character oriented delete may delete newlines.
c/accord/ Changes all characters (NOT lines!) between the
current character up to but not including the "a"
in "accord". (However, see Note below).
c?accord? Changes all characters betwen the current character
and the "accord", including the word "accord".
** Note: if you have "wrapscan" set (the default), a
search may wrap from the beginning of the file to
the end. This can cause unexpected results (which
is why I have "set nows" in my .exrc).
yj Yanks two lines, the current line and the one below.
yH Yanks all the lines from the top of the screen to
the current line, inclusive.
<G Dedents the lines between the current line and the
last line, inclusive. (The variable "shiftwidth"
determines the amount of dedenting.) Note that
this command turns character addresses into line
addresses (so does ">").
!}fmt Runs the lines between the current line and the
end of the paragraph through the program "fmt".
Vi combines the repeat count (if any) on the command character with
the repeat count on the motion command, so that "2y2j" yanks five
lines. Interestingly, "2y2_" yanks 4 lines (so does "2y2y") since
the _ command moves down (repeat count minus 1) lines. Beware,
however, of using repeat counts on all the motion commands; they're
not all implemented the same. 4$ moves to the end of the third
line below the current; 4^ merely moves to the first nonblank
character of the current line. '|' is apparently a synonym for
'0'; given a repeat count it goes that many characters to the right
of the beginning of the line (as if you had typed '|' (rept-1)
'l'). (Exercise for the reader: why can't you give a repeat count
to '0'?)
Capital letters do different things depending on the command. D
acts like d$; Y acts like YY. Don't ask me why. By the way,
capital ! doesn't seem to do anything :-).
Well, this article seems to be degenerating at this point, so I
guess I'd better wrap it up. Bye!
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci
UUCP: {seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris.umcp-cs at CSNet-Relay
More information about the Comp.unix
mailing list