Friday, July 30, 2010

Re: language-specific indenting?

On Fri, 30 Jul 2010, Tony Mechelynck wrote:

> On 30/07/10 03:55, Lev Lvovsky wrote:
> > So an emacs-using co-worker was surprised when he found out that *I*
> > didn't know how to do this (taking it to mean that vim didn't):
> >
> > If I'm given a perl script (I'm using this as an example since it's
> > an especially tricky thing to parse from what I understand), and
> > it's not at all indented, can perl automatically indent it for me?
> > Ideally, this would include things like datastructures, but it seems
> > in my attempts, that that's where parsing/indenting fails.
> >
> > I'm using the '=' command for indentation.
> >
> > Thank you!
> > -lev
> >
>
> Well, if you're using = for indentation, then what about gg=G (gg:move
> to line 1; ={motion}: indent whatever the cursor moves over; G:move to
> last line)?
>
> I don't use Perl, but I suppose that you have "filetype plugin indent
> on" in your vimrc (or that it sources the vimrc_example.vim), and that
> the Perl indent script sets the right options for = to work.
>

Until they get updated in Vim proper, it's probably also worth your time
to download the updated Perl syntax/ftplugin/indent scripts from:

http://github.com/petdance/vim-perl

With those versions, Perl indenting is reasonable. Without them, stock
Vim 7.2's ft=perl doesn't even handle simple conditionals very well.

--
Best,
Ben

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