Created
January 2, 2012 22:10
Vim: center current window in screen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let g:centerinscreen_active = 0 | |
function! ToggleCenterInScreen(desired_width) | |
if g:centerinscreen_active == 0 | |
let l:window_width = winwidth(winnr()) | |
let l:sidepanel_width = (l:window_width - a:desired_width) / 2 | |
exec("silent leftabove " . l:sidepanel_width . "vsplit new") | |
wincmd l | |
exec("silent rightbelow " . l:sidepanel_width . "vsplit new") | |
wincmd h | |
let g:centerinscreen_active = 1 | |
else | |
wincmd h | |
close | |
wincmd l | |
close | |
let g:centerinscreen_active = 0 | |
endif | |
endfunction | |
nnoremap <Leader>r :exec ToggleCenterInScreen(100)<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Done, thanks for the tip!