0

現在、ファイルでこのキー マッピングを使用して.vimrc、Windows Cut キーボード ショートカットをシミュレートしています。切り取り、つまり、選択したテキストをコピーして削除します。

vnoremap <C-X> "+x

このキー マッピングはmswin.vim、Vim に同梱されているスクリプトの一部ですが、私は使用しません。そのファイルからいくつかのキー マッピングのみを使用します。

次に、挿入モードでVim内からテキストを選択して押すと、テキストがコピーされて削除されますが、カーソルが数文字後ろに移動し、カーソルの真下の数値を減らすというCtrlXVimの通常のプレス動作を実行するという望ましくない副作用がありますCtrlX!

たとえば、次のコードを変更して、単語の 2 番目の出現をカットする場合は、次のコードからRenderer始めます。

Renderer.setClearColorHex(0x7DB6D5, 1.0);
Renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);

そしてこれで終わります:

Renderer.setClearColorHex(0x7DB6D5, 1.-1);  // <--- oh dear!
.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);

これにより、いくつかのバグが発生します。

このキーマップでこの望ましくない動作を回避する方法はありますか、または挿入 (SELECT) モードでテキストをカットする別のより安全な方法はありますか?

4

2 に答える 2

1

ファイル内の Snipmate プラグインと競合していましたsnipmate\after\plugin\snipMate.vim

これらの行をコメントアウトしましたが、すべて問題ありません。

" snor <bs> b<bs>
" snor <right> <esc>a
" snor <left> <esc>bi
" snor ' b<bs>'
" snor ` b<bs>`
" snor % b<bs>%
" snor U b<bs>U
" snor ^ b<bs>^
" snor \ b<bs>\
" snor <c-x> b<bs><c-x>
于 2012-02-15T19:30:59.763 に答える
0

Do you actually use mswin.vim or not? AFAIK, a lot of things are done there in order to allow editing in INSERT mode and all that kind of monstrosity; if you only take one little snippet out there's no guarantee it will work correctly.

If you use MSWIN compatibility and this mapping is already in mswin.vim, why did you put it in your vimrc?

If you don't use MSWIN compatibility, there are many wrong things here:

  • "editing" text is not done in INSERT mode, you must go back to NORMAL mode and perform your editing there
  • when in NORMAL mode, d is the correct equivalent of Ctrl+X as it deletes what you want it to delete and puts it into the default register, ready to be pasted somewhere else.
  • you don't need to select a word to delete it, supposing you are on the R of Renderer, you should do dw to delete until the end of the current word
于 2012-02-15T06:59:02.417 に答える