On 2012-09-16, Tim Johnson wrote:
> * Bee <[email protected]> [120916 09:09]:
> > 
> > 
> > On Sep 16, 9:43 am, Tim Johnson <[email protected]> wrote:
> > > Hi :
> > >
> > > Is there a way to apply the expand/retab process to a visual
> > > selection?
> > >
> > > :h ??
> > >
> > > thanks
> > > --
> > > Tim
> > > tim at tee jay forty nine dot com or akwebsoft dot 
> > > comhttp://www.akwebsoft.com
> > 
> > 
> > :help :retab
> > 
> > :[range]ret[ab][!]
> > [new_tabstop]
>  <blush> I shoulda asked for an example.
>  If I do the following
>  v    " start visual mode
>  jjjj " select 4 more lines
>  :retab  " nothing
>  :retab! " nothing
>  What else need I do?

I don't know.  It works fine for me.

Since :retab takes a range of lines, you should probably start
visual mode with V rather than v.  The latter will work, but the
range of text affected by the :retab command will be more apparent
with the former.

Example:

    :set ts=8
    :set list
    :set noexpandtab

    Enter the following text, with no leading space and using a real
    tab where <Tab> is shown.

        abc<Tab>cow
        def<Tab>chicken
        ghi<Tab>horse
        jkl<Tab>sheep
        mno<Tab>pig

    :set expandtab

    Move the cursor to "def" and type

       Vjj:retab
    
    You should see each of the tabs in those three lines replaced by 
    five spaces.

    :set noexpandtab

    Move the cursor to "def" and type

        Vj:retab

    You should see no change.  Now type

        gv:retab

    You should see the spaces replaced by tabs on the two visually-
    selected lines but not on the "jkl" line.

Do you see different behavior?

Note that :retab! will not replace a single space by a tab.

Regards,
Gary

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to