How to test if an escape sequence is currently mapped

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

How to test if an escape sequence is currently mapped

Thanks to everyone who offered very helpful suggestion regarding my previous question on the best way to conditionally map function keys using autocmd BufReadPre, when editing particular files.

I wanted to unmap the keys upon exiting the file and have done that also using aucocmd BufLeave.  However, I found that an attempt to unmap a key sequence that isn't currently mapped results in an error.  If there a way to perform a test to see if a particular key or escape sequence is mapped, and only then unmap it?  Something like:

:if ismapped <Esc>[1;3S
:    nunmap <Esc>[1;3S
:    iunmap <Esc>[1;3S

If I can do this, then I can write a single universal function that handles all conditions. 

And if there is some sort of test, is it generic to all mappings or particular to the mode such as imap, nmap, etc?


You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit

You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit