1

I have

nnoremap <C-]> :bn<Enter>
nnoremap <C-[> :bp<Enter>

so that I can use Ctrl + [ and ] to flip between buffers. I'm experiencing an issue where these two shortcuts behave differently

  • Ctrl+] instantly switches to the next buffer (good).
  • Ctrl+[ hangs for about half a second before switching to the previous buffer (bad).

Curiously, using the command :bp directly (i.e. without the Ctrl+[ remap) still instantly switches to the previous buffer as it should. Its only when invoking it with the Ctrl-[ remap that the delay occurs. This is very strange and seems to be some property of nnoremap that I don't understand.

Why would only one of these work instantly and how can I get the other one to work instantly?

1 Answer 1

3

No, this has nothing to do with :bprevious or :nnoremap.

<C-[> is the control code for <Esc>. Because it is used internally for lots of things beyond "the escape key", mapping it will cause an infinite number of weird issues. It is thus strongly recommended to leave it alone.

Technically, the timeout you are experiencing can be removed by disabling :help 'timeout' and :help 'ttimeout' and/or playing with :help 'timeoutlen' and :help 'ttimeoutlen' but it will probably cause more harm than good.

I would suggest you use different mappings and call it a day.

FWIW, this is what I use:

nnoremap <PageUp>   :bprevious<CR>
nnoremap <PageDown> :bnext<CR>

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.