问题
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