Monday, June 4, 2012

Re: Autoindenting, Match paren on the same column as variable name

On Monday, June 4, 2012 1:00:21 PM UTC-5, Colin Wood wrote:
> Hi Vim Users,
>
> I have a quick question about how to make auto indent put the last paren on the same column as the variable that defines it. This is might be for python only. But I think its pretty general.
>
> Example:
>
> # Currently VIM does this. I want to auto indent to the next example.
> NAMES = (
> 'colin',
> 'bradley',
> 'chad',
> )
>
> NAMES = (
> 'colin',
> 'bradley',
> 'chad',
> )
>
> My vimrc: https://github.com/cwood/dotfiles/blob/master/vimrc

From your .vimrc, it looks like you're using filetype indent rules, so the rules used for python will only apply to python.

Probably you'll need to either copy and modify $VIMRUNTIME/indent/python.vim, or provide your own wrapper function around the GetPythonIndent() function defined therein. There do not appear to be any options built into the python.vim indent file to allow customizing the indent of a closing ')'.

It looks like there's some "matched pair" searching built into the indent file (see the line starting with "let parlnum = searchpair("), so you can probably modify the indent script to return its internal plindent variable at an appropriate place.

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