Tuesday, April 3, 2012

Re: indenting python docstring in vim

On Apr 3, 2012, at 8:31 PM, Zetah Ghamin wrote:

> Forget what I said about Arch, it also doesn't work, but seems to produce different result as well.
>
> On Arch:
> :set
> --- Options ---
> autoindent hidden ruler syntax=python
> background=dark history=50 scroll=19 tabstop=4
> backspace=2 hlsearch shiftwidth=4 ttimeoutlen=100
> commentstring=#%s iminsert=0 showcmd viminfo='20,"500
> expandtab incsearch showmatch wildignore=*.pyc
> filetype=python laststatus=2 smartcase wildmenu
> foldmethod=indent lazyredraw smarttab window=40
> guioptions=aci lines=41 softtabstop=4
> helplang=en mouse=a suffixesadd=.py
> cinkeys=0{,0},0),:,!^F,o,O,e
> comments=s1:/*,mb:*,ex:*/,://,b:#,:XCOMM,n:>,fb:-
> completeopt=longest,menu
> diffopt=filler,iwhite
> fileencoding=utf-8
> fileencodings=ucs-bom,utf-8,default,latin1
> grepprg=grep -nH $*
> guifont=monospace 12
> include=s*\(from\|import\)
> includeexpr=substitute(v:fname,'\.','/','g')
> indentexpr=GetPythonIndent(v:lnum)
> indentkeys=0{,0},:,!^F,o,O,e,<:>,=elif,=except
> omnifunc=pythoncomplete#Complete
> statusline=%f %m %r Line: %l/%L[%p%%] Col: %c Buf: #%n [%b][0x%B]
> suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx
> ,.out,.toc,.info,.aux,.log,.dvi,.pdf,.ps,.eps,.bbl,.out,.o,.lo
> termencoding=utf-8
>
> RESULT of 1GvG=
>
> def magic(x, y):
> '''this function does magic with x and y
> :param x: the X factor (I hate that show)
> :type x: numeric
> :param y: a matrix
> :type y: array[MxN](float32,>0)
> '''
> pass
>
> class cmagic():
> def magic(self, x, y):
> '''this function does magic with x and y
> :param x: the X factor (I hate that show)
> :type x: numeric
> :param y: a matrix
> :type y: array[MxN](float32,>0)
> '''
> pass


I don't see anything in your settings that could cause this behavior.
I tried adding couple of your settings to mine to no avail.
My Vim instances on two different systems indent that code just fine:

def magic(x, y):
'''this function does magic with x and y
:param x: the X factor (I hate that show)
:type x: numeric
:param y: a matrix
:type y: array[MxN](float32,>0)
'''
pass

class cmagic(object):
def magic(self, x, y):
'''this function does magic with x and y
:param x: the X factor (I hate that show)
:type x: numeric
:param y: a matrix
:type y: array[MxN](float32,>0)
'''
pass

FWIW, these are my settings for MacVim 7.3:
:set
--- Options ---
autoindent guioptions=egmrLt langmenu=none showmatch
background=dark guitablabel=%M%t mouse=a softtabstop=4
commentstring=#%s helplang=en ruler spelllang=en_us
expandtab history=50 scroll=19 suffixesadd=.py
filetype=python hlsearch shiftwidth=4 syntax=python
guifont=Menlo:h14 incsearch showcmd wildignore=*.pyc
backspace=indent,eol,start
cinkeys=0{,0},0),:,!^F,o,O,e
cinoptions=:0,l1,g0,t0,+.5s,(.5s,u0,U1,j1
comments=s1:/*,mb:*,ex:*/,://,b:#,:XCOMM,n:>,fb:-
fileencoding=utf-8
fileencodings=ucs-bom,utf-8,default,latin1
formatoptions=croql
guicursor=n-v-c:block-Cursor/lCursor,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25
-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor-blinkwait175-blinkoff1
50-blinkon175,a:blinkon0
include=s*\(from\|import\)
includeexpr=substitute(v:fname,'\.','/','g')
indentexpr=GetPythonIndent(v:lnum)
indentkeys=0{,0},:,!^F,o,O,e,<:>,=elif,=except
listchars=tab:>-,trail:-
omnifunc=pythoncomplete#Complete
printexpr=system('open -a Preview '.v:fname_in) + v:shell_error
printoptions=paper:letter
termencoding=utf-8

and for OpenBSD Vim 7.2:

:set
--- Options ---
autoindent history=50 showcmd ttyfast
background=dark hlsearch showmatch ttymouse=xterm
commentstring=#%s incsearch softtabstop=4 wildignore=*.pyc
encoding=utf-8 ruler spelllang=en_us
expandtab scroll=11 suffixesadd=.py
filetype=python shiftwidth=4 syntax=python
backspace=indent,eol,start
cinkeys=0{,0},0),:,!^F,o,O,e
cinoptions=:0,l1,g0,t0,+.5s,(.5s,u0,U1,j1
comments=s1:/*,mb:*,ex:*/,://,b:#,:XCOMM,n:>,fb:-
fileencoding=utf-8
fileencodings=ucs-bom,utf-8,default,latin1
formatoptions=croql
include=s*\(from\|import\)
includeexpr=substitute(v:fname,'\.','/','g')
indentexpr=GetPythonIndent(v:lnum)
indentkeys=0{,0},:,!^F,o,O,e,<:>,=elif,=except
listchars=tab:>-,trail:-
omnifunc=pythoncomplete#Complete
printoptions=paper:letter

There must be something in the system settings or indent files that is clashing with your default python indentation.
Are you sure you don't have .vim/indent/* files?
Perhaps there's before/* or after/* file?

I can't see why this would work for me and not for you.
I use Linux too (just not Ubuntu or Arch) and never had issues with this.

I hope you find some missing detail here.

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

No comments:

Post a Comment