[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Reformat Ruby source code in vim?

John Lam

8/28/2006 4:06:00 AM

I'm in the process of converting to vim from emacs to help save my
hands. I'm using the excellent vim-ruby gem to syntax color my code.

One thing that I haven't figured out how to do yet in vim is
reformatting source code. I do this in emacs via ESC-CTRL-Q . It's
really useful during refactoring when moving code fragments from one
place to another.


Thanks!
-John
http://www.iu...

10 Answers

Kent Sibilev

8/28/2006 4:10:00 AM

0

ggVG=

On 8/28/06, John Lam <drjflam@gmail.com> wrote:
> I'm in the process of converting to vim from emacs to help save my
> hands. I'm using the excellent vim-ruby gem to syntax color my code.
>
> One thing that I haven't figured out how to do yet in vim is
> reformatting source code. I do this in emacs via ESC-CTRL-Q . It's
> really useful during refactoring when moving code fragments from one
> place to another.
>
>
> Thanks!
> -John
> http://www.iu...
>
>


--
Kent
---
http://www.dat...

John Lam

8/28/2006 4:19:00 AM

0

Awesome. Thanks, Kent!

-John
http://www.iu...


On 8/28/06, Kent Sibilev <ksruby@gmail.com> wrote:
> ggVG=
>
> On 8/28/06, John Lam <drjflam@gmail.com> wrote:
> > I'm in the process of converting to vim from emacs to help save my
> > hands. I'm using the excellent vim-ruby gem to syntax color my code.
> >
> > One thing that I haven't figured out how to do yet in vim is
> > reformatting source code. I do this in emacs via ESC-CTRL-Q . It's
> > really useful during refactoring when moving code fragments from one
> > place to another.
> >
> >
> > Thanks!
> > -John
> > http://www.iu...
> >
> >
>
>
> --
> Kent
> ---
> http://www.dat...
>
>

Bruno Michel

8/28/2006 7:59:00 AM

0

Hi,

gg=G works too, and it's shorter :)

--
Bruno Michel

Kent Sibilev a écrit :
> ggVG=
>
> On 8/28/06, John Lam <drjflam@gmail.com> wrote:
>> I'm in the process of converting to vim from emacs to help save my
>> hands. I'm using the excellent vim-ruby gem to syntax color my code.
>>
>> One thing that I haven't figured out how to do yet in vim is
>> reformatting source code. I do this in emacs via ESC-CTRL-Q . It's
>> really useful during refactoring when moving code fragments from one
>> place to another.
>>
>>
>> Thanks!
>> -John
>> http://www.iu...
>>
>>
>
>


John Lam

8/28/2006 3:22:00 PM

0

Ah yes - I'm still learning about motions, as well as visual mode. Now
I just have to download this information into my fingers :)

One other thing - is it possible to syntax color a ruby instance
method in vim? I spent some time this morning tweaking my .vimrc to
color things the same way the Vibrant Ink theme in Textmate does, but
the Ruby syntax file in vim doesn't seem to attempt to try and pick
out method names where there's an explicit receiver (eg.
foo.method_name).

Thanks,
-John
http://www.iu...


On 8/28/06, Bruno Michel <bruno@exceliance.fr> wrote:
> Hi,
>
> gg=G works too, and it's shorter :)
>
> --
> Bruno Michel
>
> Kent Sibilev a écrit :
> > ggVG=
> >
> > On 8/28/06, John Lam <drjflam@gmail.com> wrote:
> >> I'm in the process of converting to vim from emacs to help save my
> >> hands. I'm using the excellent vim-ruby gem to syntax color my code.
> >>
> >> One thing that I haven't figured out how to do yet in vim is
> >> reformatting source code. I do this in emacs via ESC-CTRL-Q . It's
> >> really useful during refactoring when moving code fragments from one
> >> place to another.
> >>
> >>
> >> Thanks!
> >> -John
> >> http://www.iu...
> >>
> >>
> >
> >
>
>
>

Robert Retzbach

8/28/2006 3:42:00 PM

0

It would be interesting to see how textmate does this, cause I can't
think of a way to determine whether foo.method_name is an instance
method or a class method for example.

John Lam schrieb:
> the Ruby syntax file in vim doesn't seem to attempt to try and pick
> out method names where there's an explicit receiver (eg.
> foo.method_name).

James Gray

8/28/2006 3:52:00 PM

0

On Aug 28, 2006, at 10:42 AM, Robert Retzbach wrote:

> It would be interesting to see how textmate does this, cause I can't
> think of a way to determine whether foo.method_name is an instance
> method or a class method for example.

def foo.method_name... is always a singleton class method, isn't it? ;)

James Edward Gray II


jmg3000

8/28/2006 5:19:00 PM

0

On 8/28/06, John Lam <drjflam@gmail.com> wrote:
> I'm in the process of converting to vim from emacs to help save my
> hands. [snip]

To save my hands, I switched to using the dvorak layout and also to
using this keyboard: http://www.kinesis-ergo.com/con... .
Highly recommended.

---John

James Gray

8/28/2006 5:22:00 PM

0

On Aug 28, 2006, at 11:47 AM, Robert Dober wrote:

> On 8/28/06, James Edward Gray II <james@grayproductions.net> wrote:
>>
>> On Aug 28, 2006, at 10:42 AM, Robert Retzbach wrote:
>>
>> > It would be interesting to see how textmate does this, cause I
>> can't
>> > think of a way to determine whether foo.method_name is an instance
>> > method or a class method for example.
>>
>> def foo.method_name... is always a singleton class method, isn't
>> it? ;)
>
>
> I am afraid it might be a class method

A class method is a singleton method on a class:

>> class Foo
>> foo = Foo
>> def foo.method_name
>> end
>> end
=> nil
>> Foo.singleton_methods
=> ["method_name"]

James Edward Gray II

James Gray

8/28/2006 5:33:00 PM

0

On Aug 28, 2006, at 12:26 PM, Robert Dober wrote:

> On 8/28/06, James Edward Gray II <james@grayproductions.net> wrote:
>>
>> On Aug 28, 2006, at 11:47 AM, Robert Dober wrote:
>>
>> > On 8/28/06, James Edward Gray II <james@grayproductions.net> wrote:
>> >>
>> >> On Aug 28, 2006, at 10:42 AM, Robert Retzbach wrote:
>> >>
>> >> > It would be interesting to see how textmate does this, cause I
>> >> can't
>> >> > think of a way to determine whether foo.method_name is an
>> instance
>> >> > method or a class method for example.
>> >>
>> >> def foo.method_name... is always a singleton class method, isn't
>> >> it? ;)
>> >
>> >
>> > I am afraid it might be a class method
>>
>> A class method is a singleton method on a class:
>
>
> lucky escape ;)

Not at all. That's why I said "singleton class" in the first place.

Hey man, all this singleton class stuff is just finally starting to
sink into my brain, don't set me back on the path to enlightenment! ;)

James Edward Gray II


James Gray

8/28/2006 7:44:00 PM

0

On Aug 28, 2006, at 2:12 PM, Robert Dober wrote:

> I think I read you know.
> Do you mean when defining
> def Foo.x
> it does not matter if Foo is a class or anyting else, the
> "singleton method"
> is defined on behalf of the "Object"?

I'm not sure I understood you here. What I was saying is, whenever
you see:

def abc.some_method
# ...
end

You can be sure that some_method() was just defined as a singleton
method of abc. This is often used to make "class methods" in Ruby,
but that's really just applying a familiar term to a Ruby concept.

It's always a singleton method being defined, as I understand it.

James Edward Gray II