Dimitar wrote:
* A.J.Mechelynck <[EMAIL PROTECTED]> [070314 07:50]:
How can a Vim script know if we're running without an X connection?

What about if has('gui') ?

No. This wouldn't distinguish a version -gui +x11 +clipboard +clientserver running in a non-x console (with no clipboard and no clientserver facilities) from the same version running in an xterm (where those facilities are available).


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?

For instance, I might want to map the following

        :map <S-F5> cc<C-R>+

in my vimrc, to replace the current line with the clipboard. However that mapping should not be enabled if we have no access to the clipboard. So I wrap it in

        if has("clipboard") && (&term != "linux")
                :map <S-F5> cc<C-R>+
                :imap <S-F5> <C-O>cc<C-R>+
        endif

which takes care of two cases:
- running with no clipboard support compiled-in
- running in the (non-X) linux console (aka /dev/tty)
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?


Best regards,
Tony.

Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
111. You and your friends get together regularly on IRC, even though
     all of you live in the same city.

Reply via email to