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: Lennart Borgman
Subject: Re: Textmate like code block alignment (ruby-mode)
Date: Wed, 7 Jul 2010 01:27:04 +0200

You could try tabkey2 or smart-tab to get both indentation and
snippets, see http://www.emacswiki.org/emacs/TabCompletion


On Tue, Jul 6, 2010 at 7:05 PM, Marcelo de Moraes Serpa
<celoserpa@gmail.com> wrote:
> Hi Deniz,
>
> Thanks for being so helpful ;)
>
> Well, my config has snippets attached to TAB too, so if I hit TAB, it
> will try to complete "end". I'm using a fork of emacs-starter-kit,
> and, although I have modified it a lot already, I didn't have the time
> to peek into it the way I wanted so as to understand how things are
> wired up, I'll need to to that eventually.
>
> Anyway, thanks for the suggestion. Using C-j already had this
> behaviour built-in btw,
>
> Marcelo.
>
> On Tue, Jul 6, 2010 at 12:01 PM, Deniz Dogan <deniz.a.m.dogan@gmail.com> 
> wrote:
>> 2010/7/6 Marcelo de Moraes Serpa <celoserpa@gmail.com>:
>>> 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]