Hello, * On Tue, Mar 13, 2007 at 11:29:28PM +0100, A.J.Mechelynck <[EMAIL PROTECTED]> wrote: > How can a Vim script know if we're running without an X connection? > > Of course, some cases are obvious, such as > > if has('unix') && !has('x11') > > meaning we're on Unix with no X11 support compiled-in. > > But what about an X-enabled Vim running in console mode, either with > the -X command-line switch, or in a terminal with no access to an X > server? > [...] > It doesn't take care, however, of the case when an X-enabled Vim was > started as "vim -X" in an xterm. Is there a way to check for that in > vimscript?
What about checking whether .gvimrc is sourced or not? Testing also for has('x11') could be a way to be sure vim is compiled for x11, and running with an X connection. Reading the documentation from |.gvimrc|, it seems there are a few other way to test for the fact you are running with graphics support. Unless you want to also support vim running in console, and with X-term support [1], this should do it. Otherwise, what about testing the options vim was launched with (thanks to a system('ps -relevant-options')) ? HTH, [1] I don't know whether it is relevant or not. -- Luc Hermitte http://hermitte.free.fr/vim/