home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!menudo.uh.edu!buster!uhura1!bryan
- From: bryan@uhura1.uucp (Bryan Curnutt)
- Subject: Re: Dear vi guru,
- Message-ID: <1992Sep3.163059.10935@uhura1.uucp>
- Reply-To: bryan%uhura1@uunet.uu.net
- Organization: Stoner Associates, Inc./DREM Incorporated, Houston Texas
- References: <1992Sep2.224136.24163@nsisrv.gsfc.nasa.gov> <1992Sep2.233330.18751@ncar.ucar.edu>
- Distribution: na
- Date: Thu, 3 Sep 1992 16:30:59 GMT
- Lines: 38
-
- In article <1992Sep2.233330.18751@ncar.ucar.edu> tparker@music.scd.ucar.edu (Tom Parker) writes:
- >In article <1992Sep2.224136.24163@nsisrv.gsfc.nasa.gov> schieb@shark.gsfc.nasa.gov (Brian D. Schieber) writes:
- >>Dear vi guru,
- >>
- >> I like to use tabs alot in just about every session of vi I
- >>work with, It would be great if I had a macro or whatever that
- >>could replace the tabs with the appropriate number of spaces
- >>in a file WHILE in vi. Do you have such a macro?
- >
- >Check if your system has the 'expand' command. This command converts
- >tabs to spaces, and vice versa.
-
- ... but is not what Brian asked for.
-
- Assuming your tabs are for indentation at the beginning of the line
- only, i.e. that you don't have text characters followed by tabs,
- something simple like
-
- :map g :%s/^I/ /g^M
- [tab character]^^ ^^[carriage return]
-
- will do what you want.
-
- If your system does have the 'expand' command, then something like
-
- :map g :%!expand -4^M
-
- will do the trick, and do it correctly (unlike the %s above, which
- only works if the tabs are all at the beginning or coincidentally
- aligned so they start at a tabstop).
-
- There may be a simple way to correctly expand tabs from within vi
- without resorting to external programs, but I'm not really a guru,
- just a Joe Random User.
- --
- Any opinions above are mine, and do not necessarily reflect the views of SAI.
- Bryan Curnutt
- bryan%uhura1@uunet.uu.net
-