On Tue, October 6, 2009 7:53 am, Christian Brabandt wrote:
> And then there are some settings that might interfer with the function,
> like 'sidescrolloff', 'scrolloff', 'sidescroll', 'wrap'. And then what
> would you want with a more complex window layout? Therefore I give only
> some hints, how to do what you want and no possible complex function, that
> would take care of all of these cases.
This is how far I came:
fu! <SID>WinResize(h)
let cpos=getpos('.')
let cwin=winnr()
if a:h
" Horizontal split windows
" Is there a window on top of us?
if cwin != 1
wincmd k
let owin=winnr()
endif
" same window, no window on top of current window
if cwin == 1 || owin==cwin
let size=line('.')-line('w0') + 1
let cmd='zb'
else
wincmd p
let size=line('w$') - line('.') + 1
let cmd='zt'
endif
else
" vertical split windows
" Is there a vertical Split window left of us?
if cwin != 1
wincmd h
let owin=winnr()
endif
if cwin == 1 || owin==cwin
let size=virtcol('.')
normal 0
else
wincmd p
let size=winwidth(0) - virtcol('.') + 1
let cmd=virtcol('.')-1 . 'zl'
endif
endif
exe ':' . ( a:h ? '' : 'vert ' ) . 'resize ' . size
call setpos('.', cpos)
if exists("cmd")
exe "norm " . cmd
endif
endfu
com! -bang Resize :call <SID>WinResize(empty("<bang>")?1:0)
Then you can use :Resize to resize horizontally and :Resize! to resize
vertically, which could be mapped to a key. The function seems to work,
when sidescrolloff=0, scrolloff=0, sidescroll=1 and wrap not set.
Hope that helps a little.
regards,
Christian
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---