c_CTRL-D ハック
コマンドラインでの C-d を bash の delete-char-or-list と同じように、行末では候補表示、それ以外では1文字削除にしてみた。
どうも ex コマンドラインのデフォルトキーバインドはイマイチな気がする。readline と同じでいいのに。
ポップアップメニューのキーバインドといい、この辺は Bram 氏の趣味なのだろうなあ。
--- ../src.orig/ex_getln.c Mon May 1 00:32:01 2006 +++ ex_getln.c Wed Dec 6 05:57:51 2006 @@ -13,6 +13,8 @@ #include "vim.h" +static struct cmdline_info *get_ccline_ptr __ARGS((void)); + /* * Variables shared between getcmdline(), redrawcmdline() and others. * These need to be saved when using CTRL-R |, that's why they are in a @@ -874,6 +876,7 @@ */ switch (c) { +delete: case K_BS: case Ctrl_H: case K_DEL: @@ -1141,6 +1144,15 @@ goto cmdline_changed; case Ctrl_D: + { + struct cmdline_info *p = get_ccline_ptr(); + if (p != NULL) { + if (get_cmdline_pos() != p->cmdlen || p->cmdlen == 0) { + c = K_DEL; + goto delete; + } + } + } if (showmatches(&xpc, FALSE) == EXPAND_NOTHING) break; /* Use ^D as normal char instead */
ちなみにこれはソースを変えなくても実現できる。
cnoremap <expr> <C-d> (getcmdpos()==strlen(getcmdline())+1 ? "\<C-d>" : "\<Del>")