Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to get VIM indentation and Python playing nicely?

Reply
Thread Tools

How to get VIM indentation and Python playing nicely?

 
 
Kenneth McDonald
Guest
Posts: n/a
 
      06-13-2004
I've just started to use VIM as a Python editor. However, getting
indentation to work nicely is giving me fits. I've tried a bunch
of different settings--shiftwidth, ts, etc etc.--to get tabs
working the way I want, but can't get things quite right. I'm
hoping some of you python/VIM users can help.

Here's what I want:
1) A tab displays in a width equal to four spaces.
2) <tab> always produces a tab char; it does not substitute spaces.
3) <del> (in edit mode) always deletes the previous character;
it doesn't do anything fancy.
4) <ret> (in edit mode) produces a new line below with the
same leading whitespace as the previous line _unless_ the
previous line ended with ':', in which case an additional
tab character is added.

Here's what I'm getting (settings are shiftwidth=4, ts=4,
every other tab-related setting that I can find that was
8 is four, and I've tried lots of other stuff at the same
time, such as notabexpand). Not all of this happens all
the time, but at least one of these behaviors happens no
matter what settings I've tried:
1) <del> dedents by 8 spaces: ^D dedents by 4 (which is what
I want.
2) <tab> sometimes indents by 4, and sometimes by 8, at
different places in the same file _using the same settings_.
3) Typing a ':' can cause the entire line (including what
has alrady been typed) to dedent or indent. In my view,
this is a very bad no-no.

Hopefully the solution to this sort of thing is easy. If
not, then I guess the search for an editor resumes...


Thanks,
Ken
 
Reply With Quote
 
 
 
 
Ryan Paul
Guest
Posts: n/a
 
      06-14-2004
On Sun, 13 Jun 2004 22:28:07 +0000, Kenneth McDonald wrote:

> I've just started to use VIM as a Python editor. However, getting
> indentation to work nicely is giving me fits. I've tried a bunch
> of different settings--shiftwidth, ts, etc etc.--to get tabs
> working the way I want, but can't get things quite right. I'm
> hoping some of you python/VIM users can help.
>
> Here's what I want:
> 1) A tab displays in a width equal to four spaces.
> 2) <tab> always produces a tab char; it does not substitute spaces.
> 3) <del> (in edit mode) always deletes the previous character;
> it doesn't do anything fancy.
> 4) <ret> (in edit mode) produces a new line below with the
> same leading whitespace as the previous line _unless_ the
> previous line ended with ':', in which case an additional
> tab character is added.
>
> Here's what I'm getting (settings are shiftwidth=4, ts=4,
> every other tab-related setting that I can find that was
> 8 is four, and I've tried lots of other stuff at the same
> time, such as notabexpand). Not all of this happens all
> the time, but at least one of these behaviors happens no
> matter what settings I've tried:
> 1) <del> dedents by 8 spaces: ^D dedents by 4 (which is what
> I want.
> 2) <tab> sometimes indents by 4, and sometimes by 8, at
> different places in the same file _using the same settings_.
> 3) Typing a ':' can cause the entire line (including what
> has alrady been typed) to dedent or indent. In my view,
> this is a very bad no-no.
>
> Hopefully the solution to this sort of thing is easy. If
> not, then I guess the search for an editor resumes...
>
>
> Thanks,
> Ken


Do you have the ft plugin enabled with support for python filetype? You
might want to enable autoindent or smartindent. Also, look and see if your
distribution is setting any stupid defaults. I remember redhat used to set
a bunch of wierd stuff at the site level, and I had to su to root and get
rid of it. You might want to read ':help autoindent'.

Vim takes a lot of time and patience to learn. You would probably benefit
from reading section 5 of the user-manual ('Set Your Settings').

Good Luck

--segphault

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
remove overall indentation preserving reletive indentation Jesse B. Ruby 2 03-27-2010 07:23 PM
New to Vim and Vim-Python Daniel Folkes Python 3 10-25-2007 03:51 PM
Vim two space indentation John Maclean Ruby 6 01-06-2006 08:21 AM
ANN:a Vim script make Vim suport calltips of python tocer Python 0 08-28-2004 05:32 AM



Advertisments