has("gui") issue in Terminal?

57 views
Skip to first unread message

Jason Casden

unread,
Mar 18, 2008, 9:19:07 AM3/18/08
to vim_mac
Hi,

I remap <Esc> in my .vimrc in a couple of cases, which causes problems
when running vim in a terminal. On linux, I just wrap an if has("gui")
around these mappings, but it looks like MacVim returns 1 for
has("gui"), whether it's running in the terminal or in the gui state.
Has anyone else seen this?

Thanks,
Jason

Ben Schmidt

unread,
Mar 18, 2008, 9:28:27 AM3/18/08
to vim...@googlegroups.com

I think that's how it's meant to work. I think you have to do

has('gui_running')

to test whether it's running.

Yes. I'm right. See

:help feature-list

where it explains that 'gui' means GUI is compiled in and 'gui_running' is for if
the GUI is running, or is about to be.

Perhaps on Linux the 'vim' in your path is actually a different executable, e.g. a
vim-tiny without GUI compiled in.

Ben.

Jason Casden

unread,
Mar 18, 2008, 10:57:20 PM3/18/08
to vim_mac
When I look at the feature-list, it says about "gui_running":

"Vim is running in the GUI, or it will start soon."

I take that to mean that it tells you whether the GUI version of vim
is running. Additionally, I am running the Ubuntu vim-full package on
Ubuntu. When I run it in the terminal, :echo has("gui_running")
returns 0, while running it in X using vim -g shows :echo
has("gui_running") returning 1. This seems to confirm that
has("gui_running") is meant to determine the state that vim is running
in.

Jason

Jason Casden

unread,
Mar 19, 2008, 9:15:35 PM3/19/08
to vim_mac
If this feature isn't working in the same way as it does in Linux, do
you know if there is some test I can use to see if MacVim is running
in the terminal?

Thanks,
Jason

Bem Jones-Bey

unread,
Mar 19, 2008, 10:01:54 PM3/19/08
to vim...@googlegroups.com
Are you using has("gui_running") in your .vimrc, or has("gui") in your
.vimrc? Your original mail says that you're using has("gui"), which is
different from has("gui_running").

On my Ubuntu box (with vim-full), :echo has("gui") returns 1 always
(terminal or X11). :echo has("gui_running") returns 0 in the terminal,
and 1 in X11. On Mac OS X with MacVim, :echo has("gui") and :echo
has("gui_running") seem to have the same behavior. Are you actually
seeing something different?

(One thing that might get around all of this is to put the gui only
stuff in your .gvimrc, and then you shouldn't need to do a if
has("gui_running") at all.)

Ben Schmidt

unread,
Mar 20, 2008, 12:06:32 AM3/20/08
to vim...@googlegroups.com
Jason Casden wrote:
> If this feature isn't working in the same way as it does in Linux, do
> you know if there is some test I can use to see if MacVim is running
> in the terminal?

It does work the same way as in Linux, AFAICT. If you are seeing different
behaviour, I don't think it's because of the program itself, but something in your
configuration (e.g. different binaries being run; perhaps check the :version
output is the same for both GUI and non-GUI; that has the potential to give away a
difference!).

Ben.

Jason Casden

unread,
Mar 20, 2008, 8:24:02 AM3/20/08
to vim_mac
Hi,

Sorry for my carelessness. I actually had not been using gui_running.
Sorry for the confusion, and thanks for the help.

Jason
Reply all
Reply to author
Forward
0 new messages