0

I'm using this setting:

noremap <F2> :tabnext<CR>
inoremap <F2> :tabnext<CR>

But it just moves cursor down one line like <C-j> does...

How can I map F2 to moving to next tab?

Environment: Debian 9.5 amd64, KDE

1
noremap <F2> :tabnext<CR>

Should work from within normal mode. And it works for me. Check the output of :verbose noremap <F2>.

inoremap <F2> :tabnext<CR>

Will not work. You have to add <ESC>:

inoremap <F2> <ESC>:tabnext<CR>

That is because you will invoke it from insert mode and without escape it will just issue :tabnext<CR> as a text.

  • 2
    rather use <c-o> (or even better <c-\><c-o>) instead of <esc>. This has the advantage of staying in insert mode – Christian Brabandt Oct 26 '18 at 11:15
  • Also prefer mode specific mapping command like nnoremap instead of noremap which maps the key in every modes even the ones where you don't need/want the mapping. – statox Oct 26 '18 at 11:23
  • 1
    @ChristianBrabandt, generally I agree, but in this case I would go with <ESC> because of context switching (another tab) where I would like to be in normal mode. – Maxim Kim Oct 26 '18 at 12:09
  • @MaximKim good point, indeed! – Christian Brabandt Oct 26 '18 at 12:55
0

I found the culprit - it was KDE + Gnome Terminator's fault (https://gnometerminator.blogspot.com/p/introduction.html).

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.