使用 vim 進行 Tab 鍵切換

使用 vim 進行 Tab 鍵切換

我犯了一個錯誤,就是在意識到 ubuntu 有一個單獨的網站之後才將其發佈在 unix echange 上。

我使用 Ubuntu 和 vim 作為我選擇的文字編輯器。我知道有些人使用 vim 設定快捷方式從一個選項卡切換到下一個選項卡。預設值是 gt 和 g T,但我發現這很笨拙且不自然。我想設定別名,以便可以使用 f5 切換到左側選項卡,使用 f8 切換到右側選項卡。我不確定如何更改 vimrc 頁面以獲得此結果。謝謝你!

答案1

映射鍵的一般語法為:

{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.

所以你可以嘗試在你的程式中加入以下程式碼.vimrc

nnoremap <F5> gt
nnoremap <F8> gT

其他地方有詳細教程,請參閱:

  1. http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-教學(第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

相關內容