0

假设我正在编辑我的 vimrc 文件,然后输入如下一行:

let xxx = 1

然后我想测试这一行,我必须进入正常模式,按':'并将这一行复制到命令迷你缓冲区...

我可以将 vim 配置为只需 1-2 次击键即可运行该行吗?或者更进一步,我可以通过 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 回答