Loading ...
Sorry, an error occurred while loading the content.

120594Re: Determining if Vim is running in text-console mode or X Windows

Expand Messages
  • Christian Brabandt
    Feb 1, 2011
    • 0 Attachment
      On Tue, February 1, 2011 10:23 am, Steve Laurie wrote:
      > Hi,
      >
      > I've searched Vim help and Google as well as done lots of
      > experimentation with no luck.
      >
      > Basically, what I'm trying to do is put something in my .vimrc file that
      > can determine if I'm starting Vim in text-console mode or in
      > gnome-terminal.
      >
      > The reason I need to do this is because I log into FreeBSD in
      > text-console. If I go into Xorg, I use startx and I use gnome-terminal
      > in Window Maker.
      >
      > I need to determine if I'm in text-console mode so I can set the term
      > setting in my .vimrc file to cons25 and if I startx, I need to set
      > t_Co=256, term to xterm-256color and set the theme to a nice 256 color
      > theme.
      > If I try to use the color settings in console mode, the screen turns red
      > and the text flashes.
      >
      >
      > I've tried the following:
      >
      > if has("x11")
      > set term=xterm-256color
      > set t_Co=256
      > colorscheme calmar256-dark
      > else
      > set term=cons25
      > colorscheme myvim
      > endif
      >
      > This didn't work. I've also tried:
      > if has("gui_running")
      > if has("gui_gtk2")
      >
      > nothing works. I've even tried the reverse ways like "if !has", but
      > still, no luck.
      >
      >
      > Can someone help me out on this?

      So you basically distinguish it by inspecting your $TERM variable. First
      determine in both situations what your $TERM is set to, then put something
      like this in your .vimrc

      if &term=~'linux'
      " This is the console on linux. I don't know for FreeBSD
      " set your console settings here.
      elseif &term=~'xterm'
      " Put your settings for X11 mode here
      endif

      regards,
      Christian

      --
      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
    • Show all 15 messages in this topic