I like the way you can move windows in wmii.
1 | 2
-----
3 | 4
if your cursor is in window 1 and you move the window to the right you
get
| 1
3 ||2
| 4
So I've tried to implement this in vim.. It works (not for preview
window) and is ugly.. Perhaps you want to try it out or have some ideas how to
improve it?
I'm creating two unnecessary buffers to not accidently exit vim..
Marc
smallvimwm.vim -------
" small vim window manager (kind of wmii.de style ;)
" move window to left/right col
let s:tmpfile='/tmp/tmpwindowfile'
if a:move=="l"
return "h"
elseif a:move=="h"
return "l"
endif
endfunction
" direction is either h=left or l=right
function! MoveHorizontal(direction)
let bufNr=bufnr("%")
exec 'mkview! '.s:tmpfile
" does a col exit on the side?
exec 'winc '.a:direction
if bufNr==bufnr("%") " no col, so just move in that direction as normal using
<c-w>H/L
exec 'winc '.toupper(a:direction)
return
endif
exec 'winc '.s:Opposite(a:direction)
"close this window
" add another window so that vim doesn't exit if it's the last one, save
" bufnr to delete it again later
new
let tmpbuf=bufnr("%")
winc j
quit
exec 'winc '.a:direction
sp
exec 'source '.s:tmpfile
exec 'bw! '.tmpbuf
endfunction
map <m-c-h> :call MoveHorizontal('h')<cr>
map <m-c-l> :call MoveHorizontal('l')<cr>
" cursor movement
map <m-s-l> <c-w>l
map <m-s-h> <c-w>h
map <m-s-j> <c-w>j
map <m-s-k> <c-w>k