gvim启动位置固定的话容易挡到东西,所以写了一段vimscript根据gnome-terminal的位置启动gvim,这样被遮住的概率就一些了。
fun! g:get_xterm_pos ()"{{{
if(!exists('$WINDOWID')) | return [] | endif
let term_rect_info = system('xwininfo -id ' . $WINDOWID .
\ '|grep "Absolute upper-left \(X\|Y\):"' .
\ "|awk -F ':' '{print $2}'")
let term_pos = split(term_rect_info)
return term_pos
endfun"}}}
fun! g:update_pos_by_xterm (adjust)"{{{
if(!has('gui_running')) | return | endif
let term_pos = g:get_xterm_pos()
if(term_pos == [])
echoerr 'update failed...'
return
endif
exe printf('winpos %d %d', term_pos[] + a:adjust[], term_pos[] + a:adjust[])
endfun"}}}
au GUIENTER * call g:update_pos_by_xterm([, ])
g:update_pos_by_xterm的adjust是微调位置,以gnome-terminal的左上角为原点,[0,0]就代表和gnome-terminal完全重叠了