How do I use VI to insert tab on multiple lines.
eg. If I had 100 lines and would like to have each line tab over 3
times.
1
2
3
4
5
.
.
.
99
100
final result:
<tab><tab><tab>1
<tab><tab><tab>2
<tab><tab><tab>3
<tab><tab><tab>4
<tab><tab><tab>5
<tab><tab><tab>....
<tab><tab><tab>99
<tab><tab><tab>100
Is there a quicker way than going to each line and using the "I" than
tab over 3 times?
In vanilla vi:
(the "^I" actually represents a tab character)
:1,100 s/^/^I^I^I/
or relative addressing:
:.,.+100 s/^/^I^I^I/
Or, with your shiftwidth set at the default of 8 and the cursor on
the first line you want to indent:
:sw=8
100>>
or any number of other movement commands combined with the ">" operator.
> :.,.+100 s/^/^I^I^I/
> Or, with your shiftwidth set at the default of 8 and the cursor on
> the first line you want to indent:
> :sw=8
> 100>>
> or any number of other movement commands combined with the ">" operator.
Or "combine" the two
:.,.+100>>>
Peppe [just for completeness]
--
"Before you criticize someone, walk
Preben "Peppe" Guldberg __/-\__ a mile in his shoes. That way, if
c92...@student.dtu.dk (o o) he gets angry, he'll be a mile away
----------------------oOOo (_) oOOo-- - and barefoot." --Sarah Jackson
Select all region in rectangular block (Ctrl-V) and then I,
3tabs, ESC. And you are done. No need to fiddle with regexes.
Matej
--
Matej Cepl, cepl...@yahoo.com
138 Highland Ave. #10, Somerville, Ma 02143, (617) 623-1488
DOS: n., A small annoying boot virus that causes random
spontaneous system crashes, usually just before saving a massive
project. Easily cured by UNIX. See also MS-DOS, IBM-DOS, DR-DOS.
-- David Vicker's .plan
> Select all region in rectangular block (Ctrl-V) and then I,
> 3tabs, ESC. And you are done. No need to fiddle with regexes.
That would be a vim solution (5.4 and later, I think, and possible
other clones, too(?)).
In vi you can get lots of beeps with
:set noflash
^V^V^V^V^V^V^V
[:version says "Version SVR4.0, Solaris 2.5.0"]
Somehow it would be nice if people asking questions about vi included
the :version output (or at the first line in the case of a vim
installed as vi). Would save us all some second guessing now that
quite a few systems have a vi clone installed as vi without people
knowing it.
Peppe
vi doesn't have the ability to select a region in the way you describe -
it is a feature of vim.
The simplest way in vi is to use the > command in combination with
either a line count or a cursor motion that defines the area to be
shifted. For instance, if the 100 lines to be shifted are followed by a
blank line (or EOF), then >} will shift those lines by one tab stop
(assuming you have shiftwidth set to the default value 8). Then do ..
to repeat that shift twice.
If there's no obvious cursor motion that defines the region, then
100>>.. is still fewer keystrokes than would be required using the
region select method available with vim.
--
Phil Reynolds http://users.computerweekly.net/fluffer/
Remove "spamaway." if replying by mail
Sorry, I overlooked that it is generic vi question.
Matej
--
Matej Cepl, cepl...@yahoo.com
138 Highland Ave. #10, Somerville, Ma 02143, (617) 623-1488
Extremism in the defense of liberty is no vice; moderation in the
pursuit of justice is no virtue.
-- Barry Goldwater (actually written by Karl Hess)