Vim grep导致角色暂时消失 [英] Vim grep causes characters to temporarily disappear
问题描述
我正在研究Steve Losh的学习Vimscript困难方式.在第32章中,我们构建了一个grep命令将结果放置在quickfix窗口中.
I am working through Learn Vimscript the Hard Way" by Steve Losh. In chapter 32 we build a grep command that puts results in the quickfix window. It looks like this:
:nnoremap <leader>g :silent :exe "grep! -R " . shellescape(expand("<cWORD>")) . " ."<cr>:copen<cr>
它基本上可以工作,但是当我运行它时,它将导致字符(暂时)不可见.如果我关闭并重新打开文件,字符又回来了.另外,如果我搜索不可见的字符,它们也会出现.
It basically works, but when I run it, it will cause characters to become (temporarily) invisible. If I close and re-open the file, the characters come back. Also, if I search for the invisible characters, they appear.
例如,如果我在这样的文本块上将光标放在``thedude''上运行命令:
For example, if I run the command with my cursor on ``thedude'' on a block of text like this:
thedude@abides.org
print foo(bar)
print foo(bar)
两条``打印foo(bar)''行变得不可见.有人能猜出为什么会这样吗?我正在OSX Mountain Lion上使用系统默认的Vim v7.3.
The two ``print foo(bar)'' lines become invisible. Can anybody guess why this might be happening? I'm using the system default Vim v7.3 on OSX Mountain Lion.
推荐答案
在将外部命令与:silent
命令一起使用时,有时会发生这种情况.您可以在倒数第二段的:help:silent
上进行阅读.那里告诉您可以通过执行命令后重新绘制屏幕或使用 CTRL-L
手动清除它来解决此问题.
This sometimes occurs when using an external command with the :silent
command. You can read about it at :help :silent
in the second to last paragraph. There it tells you that you can work around the problem by redrawing the screen after you execute the command or using CTRL-L
to clear it manually.
:nnoremap (yadda yadda):copen<cr>:redr!<cr>
这篇关于Vim grep导致角色暂时消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!