だいぶ前に vim-operator-inserttext 作った

任意の関数の実行結果を対象のテキストの前後に挿入またはテキストを置き換えるオペレータです.*1

function! g:Hoge(motion, wise_name)
    " wise_name = 'char', 'line' or 'block'
    return "<<" . a:motion . ">>"
endfunction

" motion の前に g:Hoge({motion}, {wise_name}) の実行結果を挿入する
map <expr> ss operator#inserttext#mapexpr(function('g:Hoge'), -1)

" motion の後ろに g:Hoge({motion}, {wise_name}) の実行結果を挿入する
map <expr> ss operator#inserttext#mapexpr(function('g:Hoge'), +1)

" motion の内容を g:Hoge({motion}, {wise_name}) の実行結果に置き換える.
" blockwise の場合には最終行を実行結果で置き換える.
map <expr> ss operator#inserttext#mapexpr(function('g:Hoge'), +0)

表を書いた時に, 合計やら平均やらを計算して挿入するとか, 他言語で評価した結果におきかえるとか, なんかできそうな気がしている.

あと, operator-furround くらいまでカスタマイズできるようにしたいけど手が動かなさそう.

*1:今週 +0 の場合(テキストを置き換える)だけのオペレータを作ろうとして存在を思い出したのでメモメモ