Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping Ctrl+[ and Ctrl+] to move between buffers in Vim

Tags:

vim

I'm trying to map Ctrl+[ and Ctrl+] to move between buffers.

I have this in my .vimrc:

nnoremap <c-[> :bprevious<CR>
nnoremap <c-]> :bnext<CR>
nnoremap <Esc> :noh<CR>

The Ctrl+] works. The Ctrl+[ trigger an :noh and I don't know why.

I would like to Ctrl+] and Ctrl+[ simply move between buffers and Esc to trigger an :nho.

like image 372
Lucas Beier Avatar asked Mar 08 '23 15:03

Lucas Beier


1 Answers

ctrl+], ctrl+ [ and ESC are already being used by vim. Mapping keys which are already being used by vim is not recommended. More at :help map-which-keys.

So, instead of mapping those keys, I would like to suggest, for example, to use F2 and F3

nnoremap <F2> :bprevious<CR>
nnoremap <F3> :bnext<CR>
like image 86
dlmeetei Avatar answered Mar 14 '23 19:03

dlmeetei