Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I often use Control+L to redraw the screen in Vim.

In particular, when I come out of sleep or change monitor configurations I often find that Vim needs to be redrawn. I thought it might be simpler to just add something to my vimrc that redraws on focus.

  • Is there a command that I can add to my .vimrc file that redraws the buffer when the window/buffer gets the focus?

In particular, a good command should have no noticeable negative performance or other related side effects.

share|improve this question
up vote 8 down vote accepted

vim has an event you can bind to for this, FocusGained, combine this with the redraw! command (the ! causes the window to be cleared first)

:au FocusGained * :redraw!

The syntax here can be read as 'automatically run the command (au is short for autocmd) :redraw! when I get the event FocusGained for any file matching the pattern *'.

to make this permanent add it to your ~/.vimrc (the leading : isnt needed in vimrc).

to test events you can use a more 'obvious' command like

:au FocusGained * :q!
share|improve this answer
Thanks. I gave it a basic test, and it seemed to work without any performance issues. – Jeromy Anglim Dec 20 '12 at 4:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.