Monday, March 28, 2011

Re: how to justify i'm in VIM or GVIM?

On 29/03/11 04:22, G G wrote:
> hi, all
>
> when i write a vim script, how can i decide whether i'm in VIM or GVIM?
> i mean, i want different colorsceme setting for each.
>
> thanks. G
>
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php

Possibility 1:
If Vim is running in GUI mode, or if it is in startup and knows that GUI
mode will be started at the end of startup, has('gui_running') returns 1
(i.e. TRUE). Otherwise it returns 0 (i.e. FALSE). You can test this
(unless running on a Vim without arithmetic evaluation) with

if has('gui_running')
" gvim-only stuff
else
" non-gvim stuff
endif

or with

if !has('gui_running')
" this won't be done when staying in console mode
endif

see
:help has()
:help feature-list
:help no-eval-feature

Possibility 2:
Whenever the GUI is started (be it during startup, or, on a Unix Vim, by
executing the :gui command at any time), your gvimrc is sourced and
(provided, of course, that autocommands are compiled-in) the GUIEnter
autocommand event is triggered. Neither happens if Vim runs in console mode.

see
:help gui.txt
:help GUIEnter


Best regards,
Tony.
--
"Oh, no! NOT the Spanish Inquisition!"
"NOBODY expects the Spanish Inquisition!!!"
-- Monty Python sketch --
"Oh, no! NOT another option!"
-- Discussion in vim-dev mailing list --

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment