2012/11/19

Twitter / kanonji

vimでカーソルキーを使うと稀に発生する「E349: No identifier under cursor」がうざい。ググっても、このエラーメッセージの翻訳定義ばかり出てくるなぁ。TERM=ansiにすると出ないというブログエントリーは有ったけどxterm-colorがいいなぁ

https://twitter.com/kanonji/statuses/270488019499356160
アレっと言っても、僕はカーソルキー使わないから発生しないんだけど、調べてみた。
まず E349 を調べる。
# grep E349 *.c
normal.c:static char *e_noident = N_("E349: No identifier under cursor");
E349 は e_noident という変数を使って発生させている。e_noident は同じく normal.c の中で2箇所から参照される。どちらもカーソル下のキーワードを探す際にキーワードとなり得る物が見つからなかった場合に発生する。
試しに「-」という文字だけタイプしてその上で K (辞書を引くキー)をタイプすると、E349 が発生する。
さて、ここでなぜ「vimでカーソルキーを使うと E349 が稀に発生する」のか。
terminfo によると xterm ではカーソルキーの左 kl は \E[D に割り当てられており、:echo getchar() によると vim ではシフトキーを押しながらカーソルキーの左を押すとこの \E[D が投げられる。

http://www.nethamilton.net/docs/termcap.html
http://linux.die.net/man/5/termcap
このキーシーケンスは xterm-color には登録されていないので
      ESC
      [
      D
の順に流れる。:help [D を見ると [D          Display all macro definitions that contain the macro
            under the cursor.  Filenames and line numbers are
            displayed for the found lines.  The search starts
            from the beginning of the file.  {not in Vi}
マクロを検索している。つまりカーソル直下のキーワードを探索しているのだ。
ゆえに、E349 が出るという事になる。
Posted at 21:01 | WriteBacks () | Edit
Edit this entry...

wikieditish message: Ready to edit this entry.






















A quick preview will be rendered here when you click "Preview" button.