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
Hi,
gg=G works too, and it’s shorter 
–
Bruno M.
Kent S. a écrit :
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 L. schrieb:
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
On Aug 28, 2006, at 10:42 AM, Robert R. 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 G. II
On 8/28/06, James Edward G. II [email protected] wrote:
On Aug 28, 2006, at 10:42 AM, Robert R. 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
look at this code
class Foo
foo = Foo # auch
def foo.method_name
…
end
Foo.methods.grep “method_name”
Ruby is full of surprises 
Cheers
Robert
James Edward G. II
On Aug 28, 2006, at 11:47 AM, Robert D. wrote:
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 G. II
On 8/28/06, John L. [email protected] 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: Kinesis Advantage2 Ergonomic Keyboard | Kinesis Keyboards and Mice .
Highly recommended.
—John
On Aug 28, 2006, at 12:26 PM, Robert D. wrote:
think of a way to determine whether foo.method_name is an
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 G. II
On 8/28/06, James Edward G. II [email protected] wrote:
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 
–
Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.
On 8/28/06, James Edward G. II [email protected] wrote:
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.
Sorry explanation below…
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! 
ok, ok, I 'll try to learn 
James Edward G. II
Hmm I was just kidding, thaught you were etc.
Now
@flags[:serious] = true
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”?
As it is Object#methods and not Class#methods I was calling in my funny
code
above.
I was not aware of that.
Thanks
Robert
Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.
On Aug 28, 2006, at 2:12 PM, Robert D. 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 G. II