repeat.vimを併用することで対応させます。
# dein.toml [[plugins]] repo = 'tpope/vim-repeat' [[plugins]] repo = 'tomtom/tcomment_vim' hook_add = ''' au MyAutoCmd VimEnter * nnoremap <silent> <Plug>RepeatTComment :TComment<Bar> \ silent! call repeat#set("\<Plug>RepeatTComment")<CR> au MyAutoCmd VimEnter * nmap <c-_><c-_> <Plug>RepeatTComment '''
解説
根幹となるのは「nnoremap <silent> <Plug>RepeatTComment
」と「nmap <c-_><c-_> <Plug>RepeatTComment
」の部分です。
前者は<Plug>RepeatTComment
に :TComment <Bar> ...
を割り当てています。:TComment
を実行したあとにsilent! call repeat#set("\<Plug>RepeatTComment")<CR>
を実行しているだけです。repeat.vimはドットを押すと、repeat#set
で登録したコマンドが実行されるようになっているので、<Plug>RepeatTComment
が呼ばれた直後にrepeat#set
で登録することで繰り返しを実現します。
これが大まかな部分で、残りのコード(au MyAutoCmd VimEnter *
など)は読み込むタイミングを制御しているだけです。
注意
上のコードではaugroup MyAutoCmd
を行っています。詳しい解説はこの記事ではしないので、以下の参考リンクなどをお読みください。