Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to set the cursor position for a mapping? For example:

nmap erb; <%= %>

I want to set the cursor after the equals sign. Can this be done?

share|improve this question

I am assuming you want this mapping to insert "<%= =>", so try something like this:

:nmap erb; i<%= =><esc>hh
share|improve this answer
inoremap erb; <%= %><left><left><left>
nnoremap erb; a<%= %><left><left><left>

Shall do it.

NB: there exist several plugins that help defining such mappings. For instance, with lh-brackets, the definition would be done with:

Brackets <%= \ %> -trigger=erb;
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .