Vi commenting out
Bill Campbell
linux-sxs
Mon Oct 16 18:09:45 PDT 2006
On Mon, Oct 16, 2006, Michael Hipp wrote:
>Is there any simple trick for having vi comment out a whole range of lines by
>placing a '#' in front of them? The manual method of i # ESC j is rather
>tedious if there is a big section to be done.
Position the cursor on the top line you want to comment. Press
``ma'' (Mark A) to set a mark there.
Position the cursor at the bottom of the range. Enter this
command which says to operate over the range from the marked a to
the current line ('a indicates the mark a, `b would be mark b).
:'a,.s/^/#/<RETURN>
One could also do ``I#<ESC>'' then press ``j.'' to go down a line
and repeat the previous command for as many lines as you like.
Bill
--
INTERNET: bill at Celestial.COM Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676
When the customer has beaten upon you long enough, give him what he asks
for, instead of what he needs. This is very strong medicine, and is
normally only required once.
-- The Consultant's Curse:
More information about the Linux-users
mailing list