Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inserting spaces instead of tabs in vi

1 view
Skip to first unread message

Randy Beckwith

unread,
Apr 10, 2003, 4:55:08 PM4/10/03
to
Has vi / vim learned the ability yet to insert spaces instead of tabs
when hitting the tab key or when autoindenting?

Please, lets not turn this into a discussion of "which is better: tabs
or spaces" or "just change the tab size". A simple no or detailed how
to example for yes will do. :=)

Thanks,

Randy Beckwith

Matthew Weier O'Phinney

unread,
Apr 10, 2003, 5:01:34 PM4/10/03
to
* Randy Beckwith <rpb...@yahoo.com>:

> Has vi / vim learned the ability yet to insert spaces instead of tabs
> when hitting the tab key or when autoindenting?
Yes. ':set expandtab' will do it; you can also add that line to your
vimrc.

--
Matthew Weier O'Phinney
mat...@weierophinney.net
http://matthew.weierophinney.net

Gary Johnson

unread,
Apr 10, 2003, 2:37:08 PM4/10/03
to
Randy Beckwith <rpb...@yahoo.com> wrote:
> Has vi / vim learned the ability yet to insert spaces instead of tabs
> when hitting the tab key or when autoindenting?

In vim, see

:help expandtab

Gary

Peppe

unread,
Apr 10, 2003, 6:10:42 PM4/10/03
to
Thus wrote Randy Beckwith <rpb...@yahoo.com>

> Has vi / vim learned the ability yet to insert spaces instead of tabs
> when hitting the tab key or when autoindenting?

As others have mentioned, vim can do this easily.

With vi it depends. If you are on an HP-UX machine, give this a spin

" ^I is a tab, ^V and ^T are control characters entered as ^V^V and ^V^t
:map! ^V^I ^T
:set tabstop=9999

Peppe [haven't come across other vi's where ^T works as on HP-UX]
--
Preben 'Peppe' Guldberg __/-\__ "Before you criticize someone, walk
pe...@xs4all.nl (o o) a mile in his shoes. That way, if
-----------------------oOOo (_) oOOo-- he gets angry, he'll be a mile away
http://www.xs4all.nl/~peppe/ - and barefoot." --Sarah Jackson

Randy Beckwith

unread,
Apr 11, 2003, 10:53:16 AM4/11/03
to
Thanks! That's amazing!! I can't believe the progress vi/vim is
making... Now back to the happy world of editing.


Matthew Weier O'Phinney <mat...@weierophinney.net> wrote in message news:<slrnb9bmtd...@kavalier.weierophinney.net>...

Wayne

unread,
Apr 23, 2003, 11:37:58 AM4/23/03
to
rpb...@yahoo.com (Randy Beckwith) wrote in message news:<d7432fbf.03041...@posting.google.com>...

As others have noted vim can do this internally. In "standard" VI I
usually set the tabstop option according to how I want TABS to
represented on the screen and then I pipe them though the expand
program before writing the file which will replace TAB characters with
the specified number of spaces.

---
:set tabstop=4
........

:1,$! expand -t 4
:w

0 new messages