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.

I'd like to use Control+O (normal mode) for something else in Vim, and Alt+left for jump back (what Control+O usually does). Usually I'd simply map Alt+left to whatever command used to be bound to Control+O, but I can't seem to find any (for example, there's no :back or :jumpback).

How do I accomplish this?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Just map the new key to the old key, but use noremap (no re-map), so that the mapping uses the original meaning of any key on the right side of the mapping and not any new mapping that you might have given to that key.

As an example, if you

:map a b
:map b c

and you type a, you will execute the function originally bound to c. However, if you

:noremap a b
:noremap b c

and you type a, you will execute the function originally bound to b.

So in your case, your mapping would be

:nnoremap <Alt-Left> <C-O>

or

:nnoremap <A-Left> <C-O>

That will let you map <C-O> to something else.

Note: Neither of those mappings work for me on the system I'm currently using, even though the Vim documentation suggests that they should, butt this does:

:nnoremap <M-Left> <C-O>
share|improve this answer
    
Thanks, that worked and actually taught me something. –  Tin Tvrtković Dec 31 '12 at 2:09
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.