0

I try to configure my .vimrc file adding new shortcuts for my daily routing.

One of my basic operations in every single IDE is switching between "tabs". I suppose to put the same key binding for each IDE i'm using on actually and ViM also suitable for me (sometimes).

The next code (.vimrc) works perfectly with any existed file I've opened in Vim.

" Create / Navigate through Tabs
nnoremap <C-t> :tabnew<CR>
nnoremap <C-]> :tabnext<CR>

inoremap <C-t> <Esc>:tabnew<CR> inoremap <C-]> <Esc>:tabnext<CR>i

Here's just 2 commands: create new tab and move to next. But I want to move back as well!

Next code

nnoremap <C-[> :tabprevious<CR>
inoremap <C-[> <Esc>:tabprevious<CR>i

provides strange behaviour for opened files (existed only).

my vimrc screenshort

The Questions

How can I fix such shortcut code and make it correct for ViM?

hamsternik
  • 103
  • 3

1 Answers1

1

Mapping the escape key like this tends to break things because of the way certain special characters are handled (references needed/appreciated). I would also recommend avoiding <C-t> and <C-]> as they are pretty useful commands (:help CTRL-T, :help CTRL-]). You might want to know about gt and gT for navigating tabs. They also take a count.


Here's some recommended reading on tabs. Use them however you want, of course! These helped inform my workflow, though:

D. Ben Knoble
  • 26,070
  • 3
  • 29
  • 65