On Tuesday, April 3, 2012 5:07:57 PM UTC-7, Zetah Ghamin wrote:
> I do use standard 4 space indent. Perhaps copy and paste failed on google 
> group.
> 
> That said, I found that I also have no problem with indent in Arch, which has 
> the same python.vim under ${VIMRUNTIME}/indent/
> 
> I have no additional vim setting. My .vimrc is fairly minimal, but I do have 
> this line for python:
> 
> au FileType python setlocal ts=4 sw=4 sts=4 sta et fdm=indent
> 
> Don't know what's the difference between Arch and Ubuntu
> 
> --
> MZ
> 
> On Tuesday, April 3, 2012 1:01:05 PM UTC-7, Zvezdan Petkovic wrote:
> > On Apr 3, 2012, at 2:10 PM, Zetah Ghamin wrote:
> > 
> > > I am having problem indenting python doctring in vim. Since I use
> > > pycontract, a typical docstring looks like the following in which I
> > > would like the left side to be aligned:
> > > 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)
> > >       '''
> > > 
> > > But when I indent this section using either Ubuntu's default
> > > python.vim or the one from here:
> > > http://www.vim.org/scripts/script.php?script_id=974
> > > the left side does not line up whenever there is a line with
> > > parenthesis. Sometimes it affects the line before it too:
> > > 
> > > 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)
> > >       '''
> > > 
> > > Now, if I remove the parenthesis from the two lines that contain it,
> > > then re-indent the block. Everything line up on the left as intended.
> > > 
> > > Any help is appreciated.
> > 
> > 
> > I cannot reproduce this with the default Vim indenter on Mac or OpenBSD in 
> > Vim 7.3 or 7.2.  When I take your function and put it in a file, then press 
> > 1GVG= it indents like this:
> > 
> > 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)
> >       '''
> > 
> > The indentation of the first docstring line is different because you used a 
> > three space indent, and the default indent uses a standard four space 
> > indent.  Otherwise, the remaining lines were not touched and are left 
> > aligned.
> > 
> > I also tried aligning the lines with the opening quotes for a standard 
> > docstring style:
> > http://www.python.org/dev/peps/pep-0257/#multi-line-docstrings
> > After re-indenting with 1GVG= it leaves the docstring aligned:
> > 
> > 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)
> > 
> >     '''
> > 
> > Did you try this function in a separate file with the default Vim indenter? 
> >  Does it behave correctly?  If not, what other custom settings are you (or 
> > Ubuntu) using that could cause this?
> > 
> > If it indents correctly when it's alone, there may be some other indenting 
> > interaction with the text below or above it perhaps?
> > Perhaps some other parenthesis above it is not closed?
> > 
> > I'm sorry that I can't help you more, but without being able to reproduce 
> > the problem I can only guess.
> > 
> > Regards,
> > 
> >     Zvezdan

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

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