Can script detect if it is running in vim/gvim?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Can script detect if it is running in vim/gvim?

Aldo Barletta
Hi

Is it possible in script to detect if vim or gvim is running?
The reason I ask is that it would be useful to be able  to set the lines
and cols differently depending on vim started as gvim or in a console (vim).

Regards
Aldo
Reply | Threaded
Open this post in threaded view
|

Re: Can script detect if it is running in vim/gvim?

panshizhu
if has("gui_running")

HTH.
--
Sincerely
Pan, Shizhu. ext: 2221




Aldo Barletta <[hidden email]> wrote on 2005.08.22 15:59:22:

> Hi
>
> Is it possible in script to detect if vim or gvim is running?
> The reason I ask is that it would be useful to be able  to set the lines
> and cols differently depending on vim started as gvim or in a console
(vim).
>
> Regards
> Aldo

Reply | Threaded
Open this post in threaded view
|

Re: Can script detect if it is running in vim/gvim?

Pete Johns
In reply to this post by Aldo Barletta
On Mon, 2005-08-22 at 09:59:22 +0200, Aldo Barletta sent:
>Is it possible in script to detect if vim or gvim is running?
>The reason I ask is that it would be useful to be able  to set
>the lines and cols differently depending on vim started as gvim
>or in a console (vim).
>
From my .vimrc:

if has("gui_running")
  set guifont=Lucida_Console:h8:cDEFAULT
  set guicursor=a:blinkon0
  set guioptions=bgmprT
  if exists(":winpos") == 2
    winpos 0 0
  endif
  """" I like having the height of the screen but only the 80 columns.
  set lines=99999 columns=80
endif

Hope this helps;


--paj

--
Pete Johns                                          ICQ: 61363909
http://www.johnsy.com/          MSN: johnsyweb[at]hotmail[dot]com
Tel/Fax: +447092119833       AIM / Jabber / Skype / Y!: johnsyweb
Reply | Threaded
Open this post in threaded view
|

Re: Can script detect if it is running in vim/gvim?

A.J.Mechelynck
In reply to this post by Aldo Barletta
----- Original Message -----
From: "Aldo Barletta" <[hidden email]>
To: <[hidden email]>
Sent: Monday, August 22, 2005 9:59 AM
Subject: Can script detect if it is running in vim/gvim?


> Hi
>
> Is it possible in script to detect if vim or gvim is running? The reason I
> ask is that it would be useful to be able  to set the lines and cols
> differently depending on vim started as gvim or in a console (vim).
>
> Regards
> Aldo

    if has("gui_running")
        " the GUI is running or about to start
        " let's set a good-looking font
        if has("gui_gtk2")
            set guifont=Lucida\ Console\ 8
        elseif has("gui_kde")
            set guifont=Lucida\ Console/8
        elseif has("x11")
            exe "set guifont="
            \ . "-*-lucidatypewriter-medium-r-normal"
            \ . "-*-*-160-*-*-m-*-*"
        else
            set guifont=Lucida_Console:h8:cDEFAULT
        endif
        " let's maximize the gvim window
        set lines=99999 columns=99999
    else
        " this is console vim
        " console vim can never change its font
        " not every console vim can resize itself
        if exists("+lines")
            set lines=60
        endif
        if exists("+columns")
            set columns=80
        endif
    endif

see
    :help exists()
    :help has()
    :help feature-list


Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: Can script detect if it is running in vim/gvim?

Aldo Barletta
Thanks to all those who responded.

Tony Mechelynck wrote:

> ----- Original Message ----- From: "Aldo Barletta" <[hidden email]>
> To: <[hidden email]>
> Sent: Monday, August 22, 2005 9:59 AM
> Subject: Can script detect if it is running in vim/gvim?
>
>
>> Hi
>>
>> Is it possible in script to detect if vim or gvim is running? The
>> reason I ask is that it would be useful to be able  to set the lines
>> and cols differently depending on vim started as gvim or in a console
>> (vim).
>>
>> Regards
>> Aldo
>
>
>    if has("gui_running")
>        " the GUI is running or about to start
>        " let's set a good-looking font
>        if has("gui_gtk2")
>            set guifont=Lucida\ Console\ 8
>        elseif has("gui_kde")
>            set guifont=Lucida\ Console/8
>        elseif has("x11")
>            exe "set guifont="
>            \ . "-*-lucidatypewriter-medium-r-normal"
>            \ . "-*-*-160-*-*-m-*-*"
>        else
>            set guifont=Lucida_Console:h8:cDEFAULT
>        endif
>        " let's maximize the gvim window
>        set lines=99999 columns=99999
>    else
>        " this is console vim
>        " console vim can never change its font
>        " not every console vim can resize itself
>        if exists("+lines")
>            set lines=60
>        endif
>        if exists("+columns")
>            set columns=80
>        endif
>    endif
>
> see
>    :help exists()
>    :help has()
>    :help feature-list
>
>
> Best regards,
> Tony.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Can script detect if it is running in vim/gvim?

Stefan Karlsson-3
In reply to this post by Aldo Barletta
If it is for "static" settings (like 'guifont') you could also put the
gvim-only settings in .gvimrc.

When gvim starts it first sources .vimrc and then .gvimrc. My .gvimrc
looks as follows:

if has("Win32")
  set guifont=Lucida_Console:h10:cANSI
  "au GUIEnter * simalt ~x
else
  set guifont=Bitstream\ Vera\ Sans\ Mono\ 12
endif

set guioptions-=T
set guioptions-=t

colorscheme chela_light



-- Stefan

Aldo Barletta wrote:

> Hi
>
> Is it possible in script to detect if vim or gvim is running? The
> reason I ask is that it would be useful to be able  to set the lines
> and cols differently depending on vim started as gvim or in a console
> (vim).
>
> Regards
> Aldo
>
Reply | Threaded
Open this post in threaded view
|

Re: Can script detect if it is running in vim/gvim?

Sean Hubbell
Stefan Karlsson wrote:

> If it is for "static" settings (like 'guifont') you could also put the
> gvim-only settings in .gvimrc.
>
> When gvim starts it first sources .vimrc and then .gvimrc. My .gvimrc
> looks as follows:
>
> if has("Win32")
>  set guifont=Lucida_Console:h10:cANSI
>  "au GUIEnter * simalt ~x
> else
>  set guifont=Bitstream\ Vera\ Sans\ Mono\ 12
> endif
>
> set guioptions-=T
> set guioptions-=t
>
> colorscheme chela_light
>
>
>
> -- Stefan
>
> Aldo Barletta wrote:
>
>> Hi
>>
>> Is it possible in script to detect if vim or gvim is running? The
>> reason I ask is that it would be useful to be able  to set the lines
>> and cols differently depending on vim started as gvim or in a console
>> (vim).
>>
>> Regards
>> Aldo
>>
>
>
Try manipulating:


if has("gui_running")
winp 0 0
win 80 35
endif


in your .vimrc (or _vimrc),

Sean