Summary to "<tab> to space under vi" -- from original poster

Summary to "<tab> to space under vi" -- from original poster

Post by Kelvin L » Tue, 02 Jan 1990 16:26:00



Hi there!  I'm the person who asked the "<tab> to space under vi" question.
Thank you to all who responsed to my question.

Based on what I get from the mail and reading other's posting:

    There is no direct way to do it in vi, but there are work arounds.

Work arounds:
        1.  Using external filters within 'vi'.  Suppose you have a filter
            called 'detab' then you can type:
                :%!detab<cr>
            You can use either (BSD) /usr/ucb/unexpand or (SYS5) 'pr -t -i80'

        2.  Do a global replacement of <tab>.

        3.  Re-map <tab> key to insert n-<space>.
            Note for method 2 and 3:
                This isn't what I want and it won't get the desired result
                because not all <tab>'s can be replace by 8 spaces.
                Alignment problem, you know.

        4.  Use ^T and ^D instead of <tab> or re-map <tab> to ^T.
            Note for method 4:
                It only works on leading spaces/tab/indentation.

Kelvin Lam
(...!necntc!gordon!kelvin)

 
 
 

Summary to "<tab> to space under vi" -- from original poster

Post by Doug Schwar » Tue, 02 Jan 1990 19:24:00


...

Quote:> Work arounds:
>    3.  Re-map <tab> key to insert n-<space>.
>        Note for method 2 and 3:
>            This isn't what I want and it won't get the desired result
>            because not all <tab>'s can be replace by 8 spaces.
>            Alignment problem, you know.

I must be missing something here.  I thought you wanted to be able to
insert N spaces when you pressed the Tab key while in {insert/open/append}
mode in vi.  If so, this suggestion will always work (put it in your .exrc
file):

:map!<sp>^V^V<tab>^V^V<sp><sp><sp><sp><sp><sp><sp><sp>

where:

        <sp>      is a space
        <tab>     is a tab
        ^V      is control-v

Note that this assumes you are using vi on the .exrc file.
The ^V^V combination is needed, since the first one escapes
the second one which in turn escapes the <tab> or <sp>'s.

If this isn't what you want, tell me where I am amiss.

Now if you use an advanced editor, such as emacs, you could
just:

        (setq tab-width 8)
--
Doug Schwartz
Sequent Computer
Beaverton, Oregon
tektronix!ogcvax!sequent!dougs

 
 
 

1. HELP: In VI how do I ":map! <tab> <space><space>"

Hi,

In my new software group we are not supposed to use tabs in the source
files.  However, I keep hitting it by mistake.  I have done some
pretty interesting stuff with map in the past, but this one
has me stumped.  How can I get VI to map "tab" to "two spaces"?

Frank

P.S. ctl-v didn't seem to help, though I have used it before.

2. !(smbfs && O_LARGEFILE)

3. VI, replace <TAB> with <SPACE>

4. failed to patch kernel32.dll

5. >>>Compiling 2.0 problem: "asm86: Command not found" <<<

6. MP3 player for Redhat 6.1?

7. <font color="blue"><B>kmail</B></font> question

8. Multiple NIC's bus arbitration problem

9. <font color="blue"><B>modemblaster</B></font>

10. How to map <tab> to <sp><sp><sp>?

11. echo converts <nl> <tab> to spaces?

12. httpd - Error: "Expected </Directory> but saw </Directory>"

13. <><><> MOUNTING EXTENDED PARTITION <><><>