19
17

More than 5 years have passed since last update.

unite-tagを利用してジャンプした場合もctrl+tで元位置に戻る方法

Last updated at Posted at 2014-11-12

やりたいこと

unite-tagを利用してる場合、公式リポジトリのdocsにある通り、下記を.vimrcに記述することにより<C-]>を処理をデフォルトのタグジャンプからunite-tagによる移動に上書くことが出来ます。

vim.rc
autocmd BufEnter *
\   if empty(&buftype)
\|      nnoremap <buffer> <C-]> :<C-u>UniteWithCursorWord -immediately tag<CR>
\|  endif

しかしunite-tagでの移動はタグジャンプではないので、上記でタグジャンプ風に移動したとしてもタグスタックにそれが記録されることはありません。ので、当然移動後に<C-t>を押しても元の場所に帰ることはできない。悲しい。<C-t>で戻りたい。

やり方

unite-tagはunite経由でジャンプしてるので、タグスタックの代わりに:Unite jumpで元の位置に戻ることが出来ます。というわけで、<C-t>の挙動をUnite jumpで上書くことで求める挙動を得ることが出来るハズ。以下を.vimrcに記述することにより心の安寧を得ることが出来ます。

vim.rc
autocmd BufEnter *
\   if empty(&buftype)
\|      nnoremap <buffer> <C-t> :<C-u>Unite jump<CR>
\|  endif

参考

同じ様にハマっていた人がいたようで、こちらを参考にさせて頂きました。
https://twitter.com/ShougoMatsu/status/325410410771660800
unite.vimの可能性は無限大とのこと。

19
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
17