In my vimrc file, I use the following few lines to swap backtick and single-quote for convenience when I'm using marks:

for first in ['', 'g', '[', ']']
    for mode in ['n', 'x', 'o']
        exe mode . "noremap " . first . "' " . first . "`"
        exe mode . "noremap " . first . "` " . first . "'"

This works great, but has the unfortunate side effect of breaking a plugin I use due to the plugin's internal use of marks. The plugin in question is the awesome and awesomely-named ninja-feet.vim, but my question isn't really about any plugin in particular. Is there a good way to define the mappings so that they don't take effect when plugin functions are being executed? If not, what's the best way to resolve this issue?

I can think of a number of solutions that would fix my particular problem but they're basically all hacks, so I'm curious if there's a good general approach to solve these sorts of conflicts.


It's up to the plugins to use nore mappings and banged :normal! command as much as possible.

Sometimes it's not possible. That's why I don't like swapping some default keybindings.

What you can do is to implement a mechanism to activate/deactivate your mappings before using mappings and commands from other plugins. I have a very old plugin on the subject: https://github.com/LucHermitte/lh-misc/blob/master/plugin/Triggers.vim

Another possibility is to try to inject your changes in the mappings defined by the plugins you use. But as the plugin seems to play with feedkeys() I'm afraid it'll be much more complex.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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