2

I made the mistake of posting this on the unix echange originally beore realizing ubuntu had a separate site.

I'm using Ubuntu with vim as my text editor of choice. I know some people set shortcuts to switch from one tab to the next with vim. The default is g t and g T, but I find this to be clumsy and not natural. I'd like to set my aliases so I can switch to the left tab with f5, and the right with f8. I am unsure of how to change the vimrc page to get this result. Thank you!

2
  • 1
    Well.. What would you do I said there's a site for Vim too: Vi and Vim?
    – muru
    Jul 9, 2015 at 16:03
  • I would be pleasantly surprised. I didn't think it would be a separate exchange. Thanks for the information!
    – EMP7705
    Jul 9, 2015 at 18:27

1 Answer 1

1

The general syntax for mapping keys is:

{cmd} {attr} {lhs} {rhs}

where
{cmd}  is one of ':map', ':map!', ':nmap', ':vmap', ':imap',
       ':cmap', ':smap', ':xmap', ':omap', ':lmap', etc.
{attr} is optional and one or more of the following: <buffer>, <silent>,
       <expr> <script>, <unique> and <special>.
       More than one attribute can be specified to a map.
{lhs}  left hand side, is a sequence of one or more keys that you will use
       in your new shortcut.
{rhs}  right hand side, is the sequence of keys that the {lhs} shortcut keys
       will execute when entered.

So you can try adding the following codes in your .vimrc

nnoremap <F5> gt
nnoremap <F8> gT

There are detailed tutorials available elsewhere, see:

  1. http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-Tutorial(Part_1)
  2. http://www.techrepublic.com/blog/linux-and-open-source/create-custom-keybindings-in-vim/
  3. http://vim.wikia.com/wiki/Using_tab_pages
2
  • I had tried this, but I thought I was supposed to put a space between. Thanks for the answer and thanks for the resources!
    – EMP7705
    Jul 9, 2015 at 18:30
  • You are most welcome!
    – Ron
    Jul 9, 2015 at 18:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .