gm ハック
gm にカウントを受け付けるようにした。
1gm で gm と同じく現在行の画面中央の桁へ移動。
[count]gm で現在行の画面右端から1/(2^count)桁左へ移動。
--- ../src.orig/normal.c 2006-04-29 22:11:18.001000000 +0900 +++ normal.c 2006-08-25 11:32:49.484375000 +0900 @@ -7707,12 +7707,21 @@ } else i = curwin->w_leftcol; + { + int pow = 1; + int count = cap->count1; + if (count > 8) + count = 8; // avoid overflow + while (count--) + pow *= 2; + /* Go to the middle of the screen line. When 'number' is on and lines * are wrapping the middle can be more to the left.*/ if (cap->nchar == 'm') i += (W_WIDTH(curwin) - curwin_col_off() + ((curwin->w_p_wrap && i > 0) - ? curwin_col_off2() : 0)) / 2; + ? curwin_col_off2() : 0)) * (pow - 1)/ pow; + } coladvance((colnr_T)i); if (flag) {
メモ:
ウィンドウの幅や、そこから行番号を除いた部分の幅を計算するにはこのようにするらしい。
int width1 = W_WIDTH(curwin) - curwin_col_off(); int width2 = width1 + curwin_col_off2();
width1 = ウィンドウ幅−(行番号幅+折りたたみ幅…) // テキストの表示に使える幅
width2 = wrap してるときの2行目以降のテキスト表示に使える幅 // set wrap|set cpo+=n で違いがわかる
現在'cpoptions'にフラグとして使われている文字は以下の通り:
aAbBcCdDeEfFgHiIjJkKlLmMnoOpPqrRsStuvwWxXyZ!$%-+*<>#&\/{.|
使える文字がなくなったらどうするつもりなのだろう。