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