Vim grep causes characters to temporarily disappear

最后都变了- 提交于 2020-01-15 04:54:25

问题


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.

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)

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.


回答1:


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>


来源:https://stackoverflow.com/questions/20939040/vim-grep-causes-characters-to-temporarily-disappear

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!