home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10703 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.6 KB  |  50 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!Firewall!ad-22!ahusain
  3. From: ahusain@ad-22.Naitc.Com (Afsar Husain)
  4. Subject: Re: Dear vi guru,
  5. Message-ID: <1992Sep3.214812.11825@Firewall.Nielsen.Com>
  6. Sender: news@Firewall.Nielsen.Com (Usenet News)
  7. Nntp-Posting-Host: ad-22.naitc.com
  8. Organization: AC Nielsen Co., Bannockburn IL
  9. References: <1992Sep2.224136.24163@nsisrv.gsfc.nasa.gov>
  10. Distribution: na
  11. Date: Thu, 3 Sep 92 21:48:12 GMT
  12. Lines: 36
  13.  
  14. In article <1992Sep2.224136.24163@nsisrv.gsfc.nasa.gov> schieb@shark.gsfc.nasa.gov (Brian D. Schieber) writes:
  15. >Dear vi guru,
  16. > I like to use tabs alot in just about every session of vi I
  17. >work with, It would be great if I had a macro or whatever that
  18. >could replace the tabs with the appropriate number of spaces
  19. >in a file WHILE in vi. Do you have such a macro?
  20. >
  21. >Most graciously,
  22. > Brian
  23. >
  24. >p.s. please send all suggestions to switch to EMACS to /dev/null
  25.  
  26. What I have done is to map a free key such as a "w" or a "q"
  27. with a macro. This macro will replace all the tabs with 4 spaces 
  28. and then writes the file and quits the editor. You can include
  29. such a mapped macro in the ".exrc" file
  30.  
  31.     map w :1,$s/     /    /g
  32.  
  33. The above map can be accomplished in a "vi" session by the following series of key
  34. strokes. Ofcourse you have to substitute the "tab" character and the
  35. "spaces" with the desired number of spaces.
  36.  
  37.     :map w :1,$s/tab/spaces/g^V^M:wq^V^M
  38.  
  39. The control M sequence can be generated by preceding it with
  40. a control V i.e. ^V^M.
  41.  
  42.  
  43. Hope this helps.
  44.  
  45. -- 
  46. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  47. #include    <standard.disclaimer>
  48. email: ahusain@nis.naitc.com
  49.