I have several files opened in tabs in Vim. I want to switch between tabs, so I use Ctrl+left to move left (previous) and for next also. But my mapping doesn't work.

:map <C-Left> :tabprevious<CR>
:map <C-Right> :tabnext<CR>

I tried in shift+ arrow combinations. It doesn't work in command line as well as vimrc also.

  • 3
    Why not gt and gT? – romainl May 10 '16 at 7:33
  • 1
    Thanks. It works. :) Can you tell me what causes my mapping not to work? – SibiCoder May 10 '16 at 7:39
  • 4
    @SibiCoder Maybe because Vim didn't set up the modified arrow keys. In your vimrc, you could try adding this line exe "set <xRight>=\e[1;*C" | exe "set <xLeft>=\e[1;*D". If this doesn't work, could you post what is displayed in a Vim buffer when you insert a literal <C-Left> (<C-V> then <C-Left> in insert mode)? Or maybe <C-Left> is already bound to some function in your terminal emulator, so Vim never receives this keystroke. – user9433424 May 10 '16 at 7:44
  • 2
    I can say that it works for me. Maybe (just maybe) you've remapped arrows or something. You can try show us your vimrc. – user1685095 May 10 '16 at 7:44
  • 4
    Try with $ vim -Nu NONE. – romainl May 10 '16 at 9:25

Your Answer

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

Browse other questions tagged or ask your own question.