4

I'm using MacVim on OSX 10.11 El Capitan, which still has some issues with El Captain's new Split Screen feature – namely, MacVim automatically resizes to 191 columns, taking up most of the screen real estate.

To fix this, I have to manually set columns=95, which works perfectly except that then, the entire vim window goes black. The easiest way to fix that is <C-l> to redraw the screen.

So, I have the following mapping set up in my .vimrc:

nnoremap <Leader>ss :set columns=95<CR><C-l>

Problem is, the <C-l> command seems to come too soon after the screen is resized, so it remains black and I still have to manually redraw the screen myself. Is there any way to delay the execution of the final <C-l> command by a few ms or so (or, even fancier, to wait until the screen has been fully resized) so that I can do this all in one fell swoop?

Thanks in advance.

1 Answer 1

12

You could use the the builtin sleep function (see :h sleep).

:sleep 2<CR> lets Vim sleep for 2 seconds, :sleep 200m<CR> for 200 milliseconds. There is also the "gosleep" command in normal mode, e.g. 2gs.

2
  • 2
    Brilliant! That did it for me. For anyone interested, here's what my mapping looks like now: nnoremap <Leader>ss :set columns=95<CR>:sleep 5m<CR><C-l>
    – Ryan Lue
    Commented Nov 29, 2015 at 16:18
  • Okay if you can slip a : cmd in there. But how about keymap to auto-select first spell correction suggestion - you can't say z=:sleep 200ms<cr><cr>1<cr>, which is just the sort of thing it seems you need to do to, because the spellcheck itself is too sleepy to accept z=<cr>1<cr> (which works perfectly well when you do it by hand).
    – markling
    Commented Jul 4 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.