This is an editor question for Ruby. I've seen the demo of RoR
where textmate is widely used. Among the others, the most
interesting feature was automatic code generation like
This is an editor question for Ruby. I've seen the demo of RoR
where textmate is widely used. Among the others, the most
interesting feature was automatic code generation like
forin
=>
for <cursor here> in <collections>
Not sure if pre-existing stuff exists for this (but I think so) but you can use vim mappings for this.
This is an editor question for Ruby. I've seen the demo of RoR
where textmate is widely used. Among the others, the most
interesting feature was automatic code generation like
Does anybody have a nice solution for automatic code generation
for Ruby in VIM?
you may have a look at the file plugin/imaps.vim from the latex-suite
project. Taken from the header of that file:
Motivation:
this script provides a way to generate insert mode mappings which do not
suffer from some of the problem of mappings and abbreviations while
allowing cursor placement after the expansion. It can alternatively be
thought of as a template expander.
<<<
The script supports place holder and more. I did not try yet, but I am
shure this script might proove quite usefull for ruby editing as well.
On a side note, has anyone got code generation (e.g. adding "end") working with Vim in the console on Linux? It only work with GVim for me -- the console version doesn't recognize the shift key or something... Anyone?
I haven't been able to work on it for a while, but snippet magic is for this exact purpose, in vim. Actually, the TextMate snippet definitions are all open source and available in a public repository so I converted them to YAML and now use them as the basis for snippet magic's default definitions. Give it a try and see what you think. Lots of people have sent mail or posted that they are using it, but it does still have some issues that need to be fixed. (A better binding for ruby-vim would help a lot here...) I'll try to get back to it soon, but if anyone wants to help out that would be great.
On a side note, has anyone got code generation (e.g. adding "end")
working with Vim in the console on Linux? It only work with GVim for me
-- the console version doesn't recognize the shift key or something...
Anyone?
I haven't been able to work on it for a while, but snippet magic is for
this exact purpose, in vim. Actually, the TextMate snippet definitions
are all open source and available in a public repository so I converted
them to YAML and now use them as the basis for snippet magic's default
definitions. Give it a try and see what you think. Lots of people have
sent mail or posted that they are using it, but it does still have some
issues that need to be fixed. (A better binding for ruby-vim would help
a lot here...) I'll try to get back to it soon, but if anyone wants to
help out that would be great.
I've tried snippet magic, but I can't figure out how to use. As an example,
when I type 'forin<tab>' it expands like
for element in collection
element.
end
and my cursor is at 't' of 'element*t*'. And the status of vim is
command-mode.
(The mode after <ESC> key is pressed)
Now, what I have to do? Because my cursor is at 't' of 'element', I can't
change
the name of element using 'cw'. I just stuck.
caw should do what you want, I think? Surely it's collection that you want to change the name of, though? I mean, in a for loop, the inner loop variable name is less likely to be important than the collection name?
I've tried snippet magic, but I can't figure out how to use. As an example,
when I type 'forin<tab>' it expands like
for element in collection
element.
end
and my cursor is at 't' of 'element*t*'. And the status of vim is
command-mode.
(The mode after <ESC> key is pressed)
Now, what I have to do? Because my cursor is at 't' of 'element', I can't
change
the name of element using 'cw'. I just stuck.
Hmmm. This has been one of the most frustrating things about this thing. For some it works just fine, and others it falls on its face. I don't know if it has to do with vim versions, preset mappings or what. One problem is that since the ruby bindings are so minimal many commands on the buffer have to be done by passing vim-script through ruby. I think this makes it susceptible to mappings and a mess of other junk, as opposed to a true binding that would have ruby methods directly operating on the buffer. Anyway...
What should happen in this case is that 'element' should be highlighted in select mode. (Highlight something in visual mode and type <ctl>-g) When you type it will change the word to whatever variable name you want, and when you hit tab it will automatically update the mirrors of that element, which in this case means the variable in the body. The idea is that you tab through the snippet, editing the important bits and tab jumping to where you want to be next.
Once the term is over at the end of this month I'll get more serious about this again.