views:

88

answers:

3

I type <%= often enough in rails that I want to find a shortcut for it. I am looking for a VIM solution (I specifically use macVim)

I know I can map it to keys or create my own snippetMate.vim snippet but I'm wondering if there's a generally accepted way of doing this.

A: 

The snippet way seems the best way to do that.

shingara
Snippets is the solution I went with. I'm using the letter 'e' for this case in .irb files. The mnemonic I think of is "equal sign". I also use 'r' for when I want the same thing w/ out the =
iljkj
+1  A: 

Vim has abbreviations functionality out of the box. Enter:

:ab < <%=

then when you type < followed by <SPACE> in insert mode it will expand to <%=.

See :help :ab for more information.

Dave Kirby
That way this abbreviation will annoyingly fire up in a comparison statements like "if x < y"
buru
@buru: That is true, but you are going to have exactly the same issue with snipmate or any of the other snippet plugins. you can use any other text you want to trigger the abbreviation, it does not have to start with the same characters. If you want a control or alt key combination you would need to use map.
Dave Kirby
+1  A: 

tpope has created a plugin that you might find useful called Ragtag

It comes bundled with many mappings, but specifically the following

Mapping       Changed to   (cursor = ^) ~
<C-X>=        foo<%= ^ %>  

tpope has a great collection of plugins:

If you are doing any rails development I would highly suggest you look into rails.vim

Peter Rincker