Ok, I trust you guys! Thanks for all the help!

Arménio Pinto


-----Original Message-----
From: Gerald Lai [mailto:[EMAIL PROTECTED]
Sent: terça-feira, 9 de Maio de 2006 17:37
To: Arménio Pinto
Cc: vim mailing list
Subject: RE: Indentation and blank lines


On Tue, 9 May 2006, Arménio Pinto wrote:

> > -----Original Message-----
> > From: Jürgen Krämer [mailto:[EMAIL PROTECTED]
> > Sent: terça-feira, 9 de Maio de 2006 16:04
> > To: vim mailing list
> > Subject: Re: Indentation and blank lines
> >
> >
> >
> > Hi
> >
> > Arménio Pinto wrote:
> >>
> >>      I'm using Vim to edit Java code. There's an annoying behavior
> >> that I would like to fix, but haven't had any success yet. The problem
> >> is that the indentation "disappears" when you insert blank lines. For
> >> example (and suppose that the "»" it's a tab):
> >>
> >> Vim does...
> >>
> >> »    »    for (String name: names) {
> >> »    »    »    System.out.println("name="+name);
> >>
> >> »    »    »    System.out.println("Done);
> >> »    »    }
> >>
> >> ... and I would like it to be:
> >>
> >> »    »    for (String name: names) {
> >> »    »    »    System.out.println("name="+name);
> >> »    »    »
> >> »    »    »    System.out.println("Done);
> >> »    »    }
> >>
> >> That is, after the first "println" I hit ENTER twice and I and would
> >> like that the blank line remains with indentation. How can I do this?
> >
> > insert any character and delete it immediately. You can put this in a
> > mapping which replaces the original behaviour of ENTER:
> >
> >  :inoremap <cr> <cr>X<bs>
> >
> > Regards,
> > Jürgen
>
> It works, thanks! Isn't this a kind of nasty trick? :-) Does anyone know a 
> cleaner solution?
>
> Arménio Pinto

Not a nasty one really. Jürgen's suggestion works well.

You can do

   :inoremap <CR> <CR><Left><Right>

if it eases your conscience ;)

--
Gerald

Reply via email to