0

vimrc ファイルを編集しているとします。次のような行を入力します。

let xxx = 1

次に、この行をテストしたいので、通常モードに入り、「:」を押して、この行をコマンドミニバッファにコピーする必要があります...

1〜2回のキーストロークでラインを実行するようにvimを設定できますか? または、さらに一歩進んで、強調表示された (ビジュアル モード) コード領域を 1 ~ 2 キー ストロークで実行できますか? 誰かがすでにそのようなことをしているはずだと思いますが、グーグルやここで見つけることができませんでした.

ありがとう!

4

1 に答える 1

0
":[range]Execute        Execute text lines as ex commands.
"               Handles |line-continuation|.
" The same can be achieved via "zyy@z (or yy@" through the unnamed register);
" but there, the ex command must be preceded by a colon (i.e. :ex)
command! -bar -range Execute silent <line1>,<line2>yank z | let @z = substitute(@z, '\n\s*\\', '', 'g') | @z

" [count]<Leader>e  Execute current [count] line(s) as ex commands, then
" {Visual}<Leader>e jump to the following line (to allow speedy sequential
"           execution of multiple lines).
nnoremap <silent> <Leader>e :Execute<Bar>execute 'normal! ' . v:count1 . 'j'<CR>
xnoremap <silent> <Leader>e :Execute<Bar>execute 'normal! ' . v:count1 . 'j'<CR>
于 2012-08-27T15:21:33.350 に答える