Quantcast

Simple Environment Questions

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Simple Environment Questions

Tyson Roberts
How does one go about detecting whether vim was executed from within MacVim/gvim/in a command terminal?

I'm trying to come up with a robust, relocatable vimrc framework at this point, now that I'm working on windows/mac/linux simultaneously.

Also, anyone know a simple test to see if a g:fred variable has been defined or not?  I'm having trouble with that one (and kind of embarrassed I haven't found the answer after all these years). -_-


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_mac" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Simple Environment Questions

Björn Winckler

2009/10/9 Tyson Roberts:
> How does one go about detecting whether vim was executed from within
> MacVim/gvim/in a command terminal?
>
> I'm trying to come up with a robust, relocatable vimrc framework at this
> point, now that I'm working on windows/mac/linux simultaneously.
>
> Also, anyone know a simple test to see if a g:fred variable has been defined
> or not?  I'm having trouble with that one (and kind of embarrassed I haven't
> found the answer after all these years). -_-

Hi Tyson,

I'm not sure this is what you are looking for, but have you tried

if has("gui_macvim")
  ...

The help on ":h feature-list" and ":h has()" may be of help.

Björn

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_mac" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Simple Environment Questions

Tyson Roberts
Thanks Bjorn, that's exactly what I needed!

(Was trying to detect both if and what gui vim was running in so that I could do some custom things on each platform/environment.)

- Tyson

On Sat, Oct 10, 2009 at 12:02 AM, björn <[hidden email]> wrote:

2009/10/9 Tyson Roberts:
> How does one go about detecting whether vim was executed from within
> MacVim/gvim/in a command terminal?
>
> I'm trying to come up with a robust, relocatable vimrc framework at this
> point, now that I'm working on windows/mac/linux simultaneously.
>
> Also, anyone know a simple test to see if a g:fred variable has been defined
> or not?  I'm having trouble with that one (and kind of embarrassed I haven't
> found the answer after all these years). -_-

Hi Tyson,

I'm not sure this is what you are looking for, but have you tried

if has("gui_macvim")
 ...

The help on ":h feature-list" and ":h has()" may be of help.

Björn




--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_mac" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Simple Environment Questions

Tony Mechelynck

On Oct 9, 5:26 pm, Tyson Roberts <[hidden email]> wrote:

> Thanks Bjorn, that's exactly what I needed!
>
> (Was trying to detect both if and what gui vim was running in so that I
> could do some custom things on each platform/environment.)
>
> - Tyson
>
> On Sat, Oct 10, 2009 at 12:02 AM, björn <[hidden email]> wrote:
>
> > 2009/10/9 Tyson Roberts:
> > > How does one go about detecting whether vim was executed from within
> > > MacVim/gvim/in a command terminal?
>
> > > I'm trying to come up with a robust, relocatable vimrc framework at this
> > > point, now that I'm working on windows/mac/linux simultaneously.
>
> > > Also, anyone know a simple test to see if a g:fred variable has been
> > defined
> > > or not?  I'm having trouble with that one (and kind of embarrassed I
> > haven't
> > > found the answer after all these years). -_-
>
> > Hi Tyson,
>
> > I'm not sure this is what you are looking for, but have you tried
>
> > if has("gui_macvim")
> >  ...
>
> > The help on ":h feature-list" and ":h has()" may be of help.
>
> > Björn

Yes: I'm not sure about MacVim but I know that the various flavours of
"X11 Vim" can run either in GUI mode or in Console mode with a single
executable, and that in that case the ":gui" command allows to go from
Console to GUI at any time after startup. So you may have to note the
differences between

        has('gui')
                compiled with GUI support
        has('gui_gtk2')
        has('gui_macvim')
        has('gui_mac')
        has('gui_proton')
        has('gui_motif'')
        has('gui_win32')
                etc.: compiled with a certain GUI flavour (see them all under ":help
feature-list")
        has('gui_running')
                either running in GUI mode, or (during startup) about to start the
GUI

I'm not sure whether has('gui_mac') is TRUE or FALSE in MacVim, nor
exactly to which Macintosh OSes it corresponds (GUI for any MacOS? for
MacOS9 or lower? other?). It is possible for more than one of the
gui_* features to be satisfied in a single executable: for instance
mine (Linux GUI for GTK2/Gnome2) answers 1 to all three of has
('gui_gtk'), has('gui_gtk2') and has('gui_gnome').

Also, when the GUI is started (be it during startup or, in the case of
a GUI executable with Console-mode support, possibly later in response
to the ":gui" command), it sources the system gvimrc (if found),
your .gvimrc or _gvimrc (on Unix-like systems, .gvimrc is tried first,
then _gvimrc if not found; on Dos-like systems it's the opposite), and
runs the autocommands for the GUIEnter event (provided, of course,
that it is compiled with the +autocmd feature, which, for a GUI-
enabled Vim, is usually the case).

The locations where Vim looks for the system gvimrc and for the user
[._]gvimrc are mentioned near the middle of the output of the
":version" command. These locations may be modified at compile-time;
if they aren't, the system gvimrc is $VIM/gvimrc (with no dot or
underscore) and the user .gvimrc is $HOME/.gvimrc (and Vim tries an
underscore if it doesn't find it with a dot, or vice-versa on Dos/
Windows). To know what these environment variables mean to Vim, type
":echo $VIM" or ":echo $HOME" (without the double quotes in both
cases, of course) in a running Vim.


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
180. You maintain more than six e-mail addresses.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_mac" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Loading...