tags:

views:

113

answers:

3

Hi,

I'm just starting learning Ruby and decided "wth, let's pick up vim and get used to it in the process". That sounded like a great idea until I actually downloaded gvim and started ... staring at it. Ok, I'm not a total noob, I know how really basic things are done in vim, what I'm looking for is how to setup vim and what plugins I need to have a complete easy-to-use workspace. I searched on the internet but didn't find anything that was straightforward enough for someone who's just starting, plus most of the articles are old.

Any suggestions guys ?

PS : Just to be clear, I'm not looking for a RoR solution, I'm using vim strictly for Ruby development, no Rails involved at all.

+1  A: 

Are you asking for tips on using vim in general, or specifically vim with ruby? For the former, don't worry about the articles being dated; vi, which vim is based-on, is 30+ years old.

vim-ruby is probably a good start, a lot of handy features: http://vim-ruby.rubyforge.org/, but truth is none of it really necessary, it just streamlines your process.

If you want more of a full-fledged IDE, RubyMine is nice.

daryn
Nah I'm talking about Ruby integration with vim. I'd like to be able to quickly create or open a ruby file, edit it (with syntax highlighting, code completion etc ...), save it and run it. I know about RubyMine but it's more oriented towards RoR development.
DrunkenBeard
check out vim-ruby then, and also, FWIW, most of the RoR tools encompass non-rails Ruby stuff as well, so they're worth a try.
daryn
Don't current versions of Vim already come with up-to-date vim-ruby support?
Telemachus
+1  A: 

Tim Pope is a Rubyist who has written a bucket of useful Vim plugins. I especially like vim-pathogen - which is a meta-plugin to manage other plugins - and vim-endwise - which automatically appends an end as appropriate when you start a do or if block.

Telemachus
+1  A: 

Code completion in vim is kind of meh. It is mostly useful when you have a gigantic variable name you don't feel like typing, it will basically just show everything from open buffers when you hit ctrl-p

For opening files, try out either FuzzyFileFinder_Textmate (this can be a pain to set up), or Command-T.Both will do recursive fuzzy searches starting from where you are.

What you really need to learn to go from beginner to intermediate is really grokking how the commands work. It is basically an extremely terse programming language.

For example, yaw will copy the word your cursor is currently in. y is the verb (will do a copy), a is the modifier (means copy the whole thing, not just from where the cursor is) and w is the noun (copy a word). Learning commands like yaw aren't going to get you that far unless you fully understand each piece. If you grok it, next time you want to delete a word, you just need to figure out that the delete command is d, and you will realize that daw will be the way to go.

Another thing to realize is how powerful . is. . will repeat any command that is in your command buffer. So, if I type daw, I delete a word. I move my cursor to the next word and hit . again, which will delete that word too.

But what happens if I want to delete a word and replace it with something else? daw kills it, i drops you into insert mode, you type out the replacement and hit esc. Ok, but was that repeatable? a . now will just repeat the word you copied, not delete the current word.

However, if you typed caw (c will delete, then drop you into insert mode), then the word you want to replace, and esc, your inserting is rolled into the same command as the delete. That means you can . and repeat the same change at another line.

This is immensely powerful. Eventually, you learn what you can dot and what you can't, and mold your workflow around it.

To start with that stuff, I would start by :h text-objects, which will give you a rundown of the common "nouns", and a bunch of modifiers. There really isn't anything as good as actually having a vim master on hand to answer your questions though.

Matt Briggs