Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers 2

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

:nmap erb; i<%= =><esc>hh
share|improve this answer
add comment
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.