1

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.

3

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.

  • 1
    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 Nov 29 '15 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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