3

If my vimrc file has the following:

inoremap ( ()<Left>  

which essentially auto-closes a (, changing it to () whenever I type ( in insert mode.

How do I undo the change when I don't want that to happen?

3
  • please read the documentation: :h :iunmap Nov 1, 2023 at 17:30
  • What are the circumstances in which you don't want it to happen? Are you perhaps looking for :help filetype?
    – Rich
    Nov 1, 2023 at 21:00
  • When using regular expressions to process just an open parenthesis for example
    – siralbert
    Nov 2, 2023 at 12:16

2 Answers 2

6

You can bypass mappings (among other things) with Ctrl-V: <C-v>( should enter a ( without executing the mapping.

3

If you usually want to insert the closing parenthesis and occasionally don't want it to be added, you could define another mapping such as

inoremap (( (

This will allow you to type a single opening parenthesis by pressing (( quickly.

As this mappings is also non-recursive, it won't trigger the original one.

The only caveat is that Vim will now wait for a brief moment after you type ( and wait if another parenthesis is to follow and which mapping is to be used.

You could choose to map any other sequence but my feeling is that the same character repeated twice is about as fast and easy to remember as it can get.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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