LoginSignup
3
3

More than 5 years have passed since last update.

Vim で 2つの textobj の対象を入れ替える operator つくった

Posted at

ブログ記事からの転載です。
つくりました。
と、いっても最初に公開したのは2年ぐらい前なんですが。

[プラグイン]

NeoBundle "osyo-manga/vim-operator-swap"

[使い方]

<Plug>(operator-swap-marking) で対象の textobj を設定し、<Plug>(operator-swap) で対象の textobj と入れ替えます。

swap

[設定例]

nmap <C-m> <Plug>(operator-swap-marking)
nmap <C-p> <Plug>(operator-swap)

[operator-highlighter と組み合わせる]

昨日つくった operator-highlighterを利用して『<Plug>(operator-swap-marking) 時に対象の textobj』をハイライトさせます。
operator をつなげるのには operator-sequence を利用します。

noremap <expr> <C-m> operator#sequence#map("\<Plug>(operator-swap-marking)", "\<Plug>(operator-highlighter)")
noremap <expr> <C-p> operator#sequence#map("\<Plug>(operator-swap)", "\<Plug>(operator-highlighter-clear)")

swap2

3
3
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
3
3