Daniel
Daniel

Reputation: 1190

Why does this Vim command wipe all characters from my terminal?

I have this function in my .vimrc, which I got here

function! SetExecutableBit()
  let fname = expand("%:p")
  checktime
  execute "au FileChangedShell " . fname . " :echo"
  silent !chmod a+x %
  checktime
  execute "au! FileChangedShell " . fname
endfunction
command! Xbit call SetExecutableBit()

When I run :call SetExecutableBit(), it works as expected. But when I run :Xbit, all characters disappear from my term (but not in Gvim). I've reproduced this on both gnome-terminal and urxvt. If I attempt to highlight some text with the mouse or ggVG, that text will reappear.

"Before" screenshot:

Screenshot of the term after running :Xbit:

Screenshot after selecting some text:


Update, since this error happens with --noplugin but does not happen with -u NONE, it must be something in my .vimrc file: https://gist.github.com/dbb/5373175

Upvotes: 1

Views: 137

Answers (1)

sidyll
sidyll

Reputation: 59277

It's probably just a matter of redrawing the screen. Try adding a :redraw to your function. If needed, appending a ! to this command will clear the screen first.

function! SetExecutableBit()
  let fname = expand("%:p")
   ...
  execute "au! FileChangedShell " . fname
  redraw
endfunction

:h :redraw

Upvotes: 1

Related Questions