Reputation: 4807
Are there any shortcuts to surround embedded Coffeescript (in eco templates) in VIM?
<%= @something %>
Whether in insert mode or not?
Upvotes: 0
Views: 194
Reputation: 4807
I wanted to add an additional alternative that I discovered later using snipMate. I could add a eco.snippets
file to the snippets directory containing:
snippet =
<%= ${1} %>
Took care of it to where I could just type =
and then tab
it into existence.
Upvotes: 0
Reputation: 13526
The surround plugin can do this. You will have to set up a custom replacement to do this. One of the examples in the surround help file actually does exactly what you want. The example says to add the line
let g:surround_61 = "<%= \r %>"
to your .vimrc
.
In this the \r
is the placeholder for whatever text you are surrounding and the 61
in the variable name means that ASCII character 61 will be the shortcut for this surround, which is =
. To use this you then use one of surround's bindings and type =
as the surround character. For example the command ysiW=
would surround the current word with <%= ... %>
. The ys
part is the key binding to add surrounding text. iW
is the motion that will be surrounded (it represents "inside word") and then =
is the surround to use, which here is set up to be a custom surround.
Upvotes: 2