Fandom

Vim Tips Wiki

Opening gvim atop a console window

Redirected from VimTip607

1,624pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Tip 607 Printable Monobook Previous Next

created November 19, 2003 · complexity basic · author drchip · version 5.7


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}" "$@"
}

CommentsEdit

Also on Fandom

Random Wiki