help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Textmate like code block alignment (ruby-mode)


From: Deniz Dogan
Subject: Re: Textmate like code block alignment (ruby-mode)
Date: Tue, 6 Jul 2010 19:01:27 +0200

2010/7/6 Marcelo de Moraes Serpa <address@hidden>:
> Hey list,
>
> I have ruby-mode setup and it works pretty well. One thing though is
> that it doesn't automatically align blocks, and I have to type C-a TAB
> to make it align the end with a def for example:
>
> def func <when I press ENTER here>
>      |<the pointer goes here>
>
> I'd like it to behave like Textmate, where when you press enter after
> the beginning of a code block, it automatically aligns the end to like
> so:
>
> def func <when I press ENTER here>
> |<the cursor goes here, where it should be>
>
> It's really annoying having to align manually.
>
> Any ideas?
>
> Thanks in advance,
>
> Marcelo.
>
>

You could try binding RET to newline-and-indent (bound to C-j by default).

Try something like this (untested):

(add-hook 'ruby-mode-hook
  (lambda ()
    (define-key ruby-mode-map (kbd "RET") 'newline-and-indent)))

By the way, you normally don't have to move the cursor anywhere to
indent the current line. Just hit TAB with the cursor anywhere on the
line you wish to indent "correctly" and it will work just as well.

-- 
Deniz Dogan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]