* allstars <[email protected]> [2009-08-27 14:03]:
> i try to remove 4 spaces in my file, so i type
> :%s/\ \{4}//g
> and it works
> 
> now i want to replace the tab with 4 spaces
> :%s/ ^I / \ \{4} /g
> but it cannot work

indeed - it cannot work because you
have not included a tab, but only
its graphical presentation as "^I".
use "\t" instead.  see ":h pattern".

besides, you can use a quantifier only
within a pattern for matching -
but not to create a sequences of
any characters in the replacement.

i guess what you want is this:
  :%s/ \t /    /g

it seems you are trying to expand
tabs to a fixed amount of space.
mind you, the expansion of a tab stops
at the next multiple of "tabstop".

as vim renders tabs and their expansion
on the screen quite nicely, it also has
a command to switch from tabs to spaces:

    :retab

mind you, tabs will only be expanded to
spaces when "expandtab" (et) is on, too.

example:
    :set tabstop=4 expandtab
    :retab

or shorter:

    :se ts=4 et|ret

you can map this, of course:

    :map <f7> :set ts=4 et|retab<cr>

enjoy!

Sven

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to