home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!Firewall!ad-22!ahusain
- From: ahusain@ad-22.Naitc.Com (Afsar Husain)
- Subject: Re: Dear vi guru,
- Message-ID: <1992Sep3.214812.11825@Firewall.Nielsen.Com>
- Sender: news@Firewall.Nielsen.Com (Usenet News)
- Nntp-Posting-Host: ad-22.naitc.com
- Organization: AC Nielsen Co., Bannockburn IL
- References: <1992Sep2.224136.24163@nsisrv.gsfc.nasa.gov>
- Distribution: na
- Date: Thu, 3 Sep 92 21:48:12 GMT
- Lines: 36
-
- 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?
- >
- >Most graciously,
- > Brian
- >
- >p.s. please send all suggestions to switch to EMACS to /dev/null
-
- What I have done is to map a free key such as a "w" or a "q"
- with a macro. This macro will replace all the tabs with 4 spaces
- and then writes the file and quits the editor. You can include
- such a mapped macro in the ".exrc" file
-
- map w :1,$s/ / /g
-
- The above map can be accomplished in a "vi" session by the following series of key
- strokes. Ofcourse you have to substitute the "tab" character and the
- "spaces" with the desired number of spaces.
-
- :map w :1,$s/tab/spaces/g^V^M:wq^V^M
-
- The control M sequence can be generated by preceding it with
- a control V i.e. ^V^M.
-
-
- Hope this helps.
-
- --
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- #include <standard.disclaimer>
- email: ahusain@nis.naitc.com
-