Back to VIM for Ruby and Rails

I learned to use VIM at the university to administrate linux systems and to develop C++ apps. Then I moved to Java and I enjoyed using an IDE like Netbeans. When I started to play with Ruby and Rails I kept using Netbeans as my editor of choice as it plays very well with them.

As I was bored with “Up arrow key, End key, Enter key” instead of “O” to insert a new line above my cursor and I wanted to play again with this so old but still alive editor, I installed the plugins: rails.vim (just great), haml syntax highlight (I ♡ haml) and irblack color scheme (more Textmate like).

With rails.vim, you get just great shortcuts to browse your rails source file. Type :Rmodel your_model_name to edit your model source file — :Rcontroller, :Rview, :Rmigration, :Rjavascript, :Rstylesheet… work too! It also includes :A (jump to alternate file) and :R (jump to relative file) commands. :A switches between source code and corresponding spec file, :R jumps from model to migration file. The most amazing combo: :AV to open up the alternative file (your spec file usually) in a vertical split window.

I finish up with the two commands I learned to use and love.1) Type ma to “mark” your cursor position as ‘a’ then type 'a to get back to this position. 2) Use qa to record a macro in ‘a’, press q again to stop recording. Then @a to replay it. Using commands to jump to next word / end of line / next something character it can be much faster than making a substitution using regexp or so.

Post to Twitter

. Bookmark the permalink. Both comments and trackbacks are currently closed.
  • Pierre-Alexandre P->

    Hi i’m started to try vim some months ago
    And because AZERTY keybord is really bad for vim i stop use it !
    Specially i don’t like the **** ecape key toooo far for my finger.
    But i finally find really good option for fix the probleme.

    So this question come from this bog:

    Here is a question: when was the last time you used the Caps Lock key on purpose?

    So actually i try to remap my keyboard for rails!
    Let’s see the result on apéroRuby-3

    French Version
    J’avais essayer vim il y a quelque temps mais j’ai rapidement arrêter car je trouvais le clavier azerty vraiment trop mauvais pour vim.
    Et surtout la touche escape si utile trop mal placé pour avoir à s’en servir si régulièrement sans ce tué les poignet.
    Je suis donc repasser à neatbean.
    Cependant je croie avoir trouvé une solution au problème.

    Remaper le clavier !!

    C’est un choix radical mais je trouve qu’il apporte beaucoup j’ai commencé à faire quelque testes et je ferai une petite présentation du résultat de mes recherches à apèroRuby-3

    see you

    • Philippe Creux

      Hey Pierre-Alexandre,

      thanks for your reply!

      I want to buy a Qwerty keyboard for my laptop since a while but never get a chance of doing it. I love the idea of remapping the CAPS LOCK key as my Escape key is pretty small and I end up pressing F1/²/1 all together. I just remapped it, I look forward getting used to it!


  • Pierre-Alexandre Pia

    i know i really take my time for reply
    but this like is really good isn’t

    so… ?

  • Joshua Born

    I, too, have used NetBeans for Rails development. I also tried Aptana’s RadRails (an Eclipse port) and most recently RubyMine. Like you, I wound up coming home to Vim for my RoR development.

    In addition to the excellent rails.vim plugin, you may want to check out the Rubytest.vim plugin for quickly running a test from within the editor, Exuberant Ctags for instantly jumping to the definition of a method or a class, the ack utility and the ack.vim plugin for searching throughout a project, the nearly ubiquitous NERD Tree plugin for files and folder browsing, and the FuzzyFinder plugin for searching through files, tags, buffers, etc.

    I go over setup tips, links, and screencasts for these plugins on my blog article for using Vim as a Ruby on Rails IDE.

  • Hi, my name is Philippe Creux.

    This blog is about Agile project management, Ruby programming and other cool things. I haven't published anything here since 2011. Find the latest and greatest on!