Sunday, November 13, 2011

True fullscreen for gvim

Note. This note is a rewriting of the 2011/11/11 original. The original worked with gvim<7.3. Now, with version 7.3 we can use a very simple method. Everyone should by now use a recent version of gvim, so I'm rewriting the note with this simple method.

So you're editing your wonderful files, and you feel that you could get more concentrated on what you're doing. In fact you realize there's a lot of junk on your screen that distracts you from this pointer-to-pointer-of-array-of-pointers-of-functions. You only wished gvim could get in full-screen mode!
Well, vim is great, the GUI version (with gtk+) of vim is great (provided you mention set go=aci somewhere in your .gvimrc file to get rid of the gui clutter), but there's no out-of-the-box full-screen mode, as far as I know. No problem, if you're using a smart Window Manager, it will help you: a possible answer to this problem is to use the very nice wmctrl program, that will work provided your Window Manager uses the NetWM standard, which is probably the case if you're using a recent and decent WM on Linux. We'll go along these lines. wmctrl is standard and should be in your distribution package repository. If not, change Linux distribution!
Put the following in your .gvimrc file, and you're done:
function! ToggleFullScreen()
   call system("wmctrl -i -r ".v:windowid." -b toggle,fullscreen")

nnoremap <M-f> :call ToggleFullScreen()<CR>
inoremap <M-f> <C-\><C-O>:call ToggleFullScreen()<CR>
Now, whenever you're in insert mode or in normal mode, typing Alt-f will toggle full screen mode.


1 comment: