On Apr 3, 2012, at 10:08 PM, Zvezdan Petkovic wrote:

> Now, I'll dig into this and find which setting fixes the issues you see by 
> gradually returning things in place.   I'll narrow this down this evening 
> probably.


I found what's causing this behavior.
My customizations for Python are not doing anything special.
The docstring is indented correctly even when ~/.vim is empty.

However, when I comment out one line in my .vimrc file the indentation changes.

It seems that you are missing this kind of setting in your ~/.vimrc file (I put 
it at the very end of that file):

if has("autocmd")
        " Enable file type detection, plugins, and indentation rules.
        filetype plugin indent on
        " ^^^^^^ DOES NOT WORK WITHOUT THAT LINE ^^^^^^
        " ...
        " vvvvvv You mentioned you have something like this already vvvvvv
        " C++, Java, JavaScript, Perl, Python and Tcl indent.
        autocmd FileType cpp,java,javascript,perl,python,tcl setl sw=4 sts=4 et
        " ...
        " vvvvvv I keep also this for doctests vvvvvv
        " reStructuredText (Python doctest) indent.
        autocmd FileType rst setlocal sw=4 sts=4 et tw=72
        " When editing a file, always jump to the last known cursor position.
        autocmd BufReadPost *
                \ if line("'\"") > 0 && line("'\"") <= line("$") |
                \       execute "normal g`\"" |
                \ endif
endif

*****
You must have "filetype plugin indent on" to get the indent to work properly.
It's best to wrap it in 'if has("autocmd") ... endif' sequence.
*****

That should solve your docstring indentation.

Couple of things that I keep in my ~/.vim/ftplugin/python.vim, but they can be 
defined in ~/.vimrc as well (if one is not sure how to write a plugin startup 
and cleanup parts):

These are useful to keep the indentation that conforms to PEP-8 style.

" Indent any continuation line 'shiftwidth' spaces
let g:pyindent_open_paren = '&sw'
let g:pyindent_nested_paren = '&sw'
let g:pyindent_continue = '&sw'

You can also add more highlight if you want:

" Highlight more
let python_highlight_all = 1

OK.  I think this should help you.
Please, tell us if this solves your indentation problems.

Regards,

        Zvezdan

-- 
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