History Report a problem
Article Edit this page Discussion

Opening gvim atop a console window

From Vim Tips Wiki

Jump to: navigation, search

Tip 607 Previous TipNext 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}" "$@"
}

[edit] Comments


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Pushing Daisies
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Astronomy Wiki
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions


Vote for featured Wikia!

Send this article to a friend
"Opening gvim atop a console window"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation