削除・ヤンクしたテキストを表示するハック
文字単位で1行以内のテキスト(要するに小レジスタ "- に入るようなテキスト)を削除・ヤンクしたときにそのテキストを"[hoge]"という感じで表示するハック。あまり役に立たない。
--- ../src.orig/ops.c Mon May 1 00:13:44 2006 +++ ops.c Sun Sep 10 22:14:25 2006 @@ -1646,7 +1646,7 @@ { oap->regname = '-'; get_yank_register(oap->regname, TRUE); - if (op_yank(oap, TRUE, FALSE) == OK) + if (op_yank(oap, TRUE, TRUE) == OK) did_yank = TRUE; oap->regname = 0; } @@ -2945,7 +2945,10 @@ && !oap->block_mode #endif && yanklines == 1) + { + smsg((char_u*)"[%s]", y_current->y_array[0]); yanklines = 0; + } /* Some versions of Vi use ">=" here, some don't... */ if (yanklines > p_report) {
テキストをプットしたあと、そのテキストの前後にスペースを入れたいことがたまにある。
そんなときのために作った関数。
function! PutSpaces() let e = getpos("']") let addedCharLen = 0 normal! `[ let c = getline(".")[col(".")-2] if c != ' ' exe "normal! i\<space>" let addedCharLen += 1 endif let e[2] += addedCharLen call setpos(".", e) let c = getline(".")[col(".")] if c != ' ' exe "normal! a\<space>" endif endfunction