1

I want to swap curly braces and brackets. The problem I encountered is that some plugin shortcuts dont trigger. Here's example. If I put this in my config file:

nnoremap { [
nnoremap [ {

then unimpaired shortcut for creating blank line doesn't work. Here's the entry from :map listing:

n  [<space>    <Plug>unimpairedBlankUp

I would expect when I press

shift { space

that plugin function will trigger. Why is this not the case? Thanks

1

The issue you're having is that your mappings are non-recursive, so they won't trigger other mappings (such as the ones from vim-unimpaired), only built-in key mappings.

In order to fix that, use nmap instead of nnoremap for the { mapping:

nmap { [

But note that you'll get into trouble if you keep the two mappings, since then it will go back to expanding the other one... Unfortunately it isn't really easy to solve that issue with Vim mappings. (You might want to consider doing a remapping at a different layer, such as your keyboard driver on the O.S.)

See :help recursive_mapping for more details.

  • Thanks. I would like to avoid remapping it at OS/keyboard layer. For instance, I want to swap numbers and symbols, but I want that only in vim where I program. I want normal numbers outside of vim. So vim would be perfect place for that... – Vjekoslav Oct 7 at 10:19

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.