[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Spaces and tabs messing up code

Robert H

1/9/2008 2:47:00 AM

mobiledreamers@gmail.com wrote:
> my friend uses vim
> and i use xemacs
> so our shared python code is a mix of tabs and spaces and it is hard for
> him to edit it in vim
>
> any idea on how to make it clean
> convert it all to 4 spaces?
>
> Thanks
>

:set ts=4
:retab!

:h retab

1 Answer

Ben Finney

1/9/2008 3:20:00 AM

0

Robert Hicks <sigzero@gmail.com> writes:

> mobiledreamers@gmail.com wrote:
> > my friend uses vim
> > and i use xemacs
> > so our shared python code is a mix of tabs and spaces and it is hard
> > for him to edit it in vim
> > any idea on how to make it clean
> > convert it all to 4 spaces?
> > Thanks
> >
>
> :set ts=4
> :retab!
>
> :h retab

ASCII TAB stops have only one defined width: 8 columns. Set "tabstop"
to 8.

Instead, use Vim's "softtabstops" feature, where the editor will
backspace over space sequences as though there were "hard tabs" there;
and the "shiftwidth" setting, to determine how many columns the
"indent" and "dedent" commands move text.

Then, use "expandtabs" so that ASCII TABs (and the <Tab> key) are
converted to space sequences. Use "retab" to convert all tabs in the
current buffer.

===== $HOME/.vim/vimrc =====
[...]

" indent shift interval (for shifting text blocks in/out)
set shiftwidth=4

" tab stop interval (for literal ASCII TAB character)
set tabstop=8

" tab stop interval (for pressing <Tab> key)
set softtabstop=4

" expand <Tab> chars to spaces?
set expandtab
=====

The important thing to do, more than a once-off conversion, is to
ensure that your project's "tabs" or "no tabs" policy is automatically
enforced from that point on for all files edited.

--
\ "In the long run, the utility of all non-Free software |
`\ approaches zero. All non-Free software is a dead end." â??Mark |
_o__) Pilgrim |
Ben Finney