Monday, February 17, 2020

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
:endif

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?

Thanks!

--
--
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 http://www.vim.org/maillist.php

---
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/b5d3ae51-4e62-45f6-8c65-064f950b94c2%40googlegroups.com.

No comments:

Post a Comment