vim でタブ移動

vim でタブ移動

Ubuntu に別のサイトがあることに気付く前に、最初にこれを Unix Exchange に投稿するという間違いを犯しました。

私は、テキスト エディターとして vim を選択した Ubuntu を使用しています。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

関連情報