Opening gvim atop a console window
From Vim Tips Wiki
Tip 607 Previous Tip • Next Tip
Created: November 19, 2003 Complexity: basic Author: drchip Minimum version: 5.7 Karma: 80/22 Imported from: Tip#607
I like to have gvim open atop the current xterm I'm using, rather like a vim console would. Here's some Korn shell script for setting up a function "gv" which queries X for the current window's geometry and adjusts the window for the current fontsize, borders, and menu region.
Admittedly the adjustments for that vary with border sizes, etc, so you'll likely need to adjust x,y,w,h in the Adjustments section.
To start gvim, type:
gv files options etc
# gv: gvim covers starting console window
function gv
{
if [[ "${WINDOWID}" = "" ]]; then
return
fi
xwi=$(xwininfo -id $WINDOWID)
xyposn=${xwi##*Corners: }
xyposn=${xyposn%% -*}
wh=${xwi##*geometry }
wh=${wh%%[-+]*}
integer x y w h
x=${xyposn%+[0-9]*}
y=${xyposn##*+}
w=${wh%x*}
hh=${wh#*x}
h=${hh%%[-+]*}
# Adjustments: account for window borders, menus, fontsizes
# Adjust for RH8 Linux: courier-12-r
h=h-4
x=x-4
y=y-18
# execute gvim with geometry
gvim -geometry "${w}x${h}+${x}+${y}" "$@"
}
