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

MacVim looks different when invoked as gvim

Expand Messages
  • dwhit
    I m running MacVim 7.2 stable 1.2/33.3 and using the mvim shell script provided with it. I have it in ~/bin/ with symlinks to it from view, vim, gview, and
    Message 1 of 12 , Apr 17, 2009
    • 0 Attachment
      I'm running 'MacVim 7.2 stable 1.2/33.3' and using the mvim shell
      script provided with it. I have it in ~/bin/ with symlinks to it from
      view, vim, gview, and gvim. $ gvim<enter> gets me a new MacVim window
      with a black bg and white text. <Cmd-N> on a running MacVim gets me a
      new MacVim window with a white bg and black text. Why the difference
      and where can I change it to act the same?

      Thanks,
      David

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tony Mechelynck
      ... Try ... in your gvimrc or in an autocommand for the GUIEnter event. Beware: I cannot try it myself, because I m not on a
      Message 2 of 12 , Apr 18, 2009
      • 0 Attachment
        On Apr 17, 9:01 pm, dwhit <dwhitma...@...> wrote:
        > I'm running 'MacVim 7.2 stable 1.2/33.3' and using the mvim shell
        > script provided with it. I have it in ~/bin/ with symlinks to it from
        > view, vim, gview, and gvim. $ gvim<enter> gets me a new MacVim window
        > with a black bg and white text. <Cmd-N> on a running MacVim gets me a
        > new MacVim window with a white bg and black text. Why the difference
        > and where can I change it to act the same?
        >
        > Thanks,
        > David

        Try
        :set bg=light
        :hi Normal guibg=white guifg=black
        :syntax enable

        in your gvimrc or in an autocommand for the GUIEnter event. Beware: I
        cannot try it myself, because I'm not on a
        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_mac" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • björn
        ... Does the same thing happen if you start MacVim using: /Applications/MacVim.app/Contents/MacOS/Vim -g from Terminal? (Assuming MacVim is installed in
        Message 3 of 12 , Apr 18, 2009
        • 0 Attachment
          2009/4/17 dwhit:
          >
          > I'm running 'MacVim 7.2 stable 1.2/33.3' and using the mvim shell
          > script provided with it. I have it in ~/bin/ with symlinks to it from
          > view, vim, gview, and gvim. $ gvim<enter> gets me a new MacVim window
          > with a black bg and white text. <Cmd-N> on a running MacVim gets me a
          > new MacVim window with a white bg and black text. Why the difference
          > and where can I change it to act the same?

          Does the same thing happen if you start MacVim using:

          /Applications/MacVim.app/Contents/MacOS/Vim -g

          from Terminal? (Assuming MacVim is installed in /Applications.)

          Björn

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_mac" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • dwhit
          On Apr 18, 5:53 am, Tony Mechelynck ... That did the trick. I was unaware of the guibg and guifg settings. I still don t
          Message 4 of 12 , Apr 20, 2009
          • 0 Attachment
            On Apr 18, 5:53 am, Tony Mechelynck <antoine.mechely...@...>
            wrote:

            > Try
            >     :set bg=light
            >     :hi Normal guibg=white guifg=black
            >     :syntax enable
            >
            > in your gvimrc or in an autocommand for the GUIEnter event. Beware: I
            > cannot try it myself, because I'm not on a

            That did the trick. I was unaware of the guibg and guifg settings. I
            still don't understand why MacVim was getting different display
            settings when invoked as gvim from the command line, but at least I
            know how to override it now.

            Thanks
            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_mac" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • björn
            ... It should not (unless there is some environment flag or something which affects this that I am unaware of). Please reply to my last post in order for me to
            Message 5 of 12 , Apr 21, 2009
            • 0 Attachment
              2009/4/21 dwhit:
              >
              >> Try
              >>     :set bg=light
              >>     :hi Normal guibg=white guifg=black
              >>     :syntax enable
              >
              > That did the trick. I was unaware of the guibg and guifg settings. I
              > still don't understand why MacVim was getting different display
              > settings when invoked as gvim from the command line, but at least I
              > know how to override it now.

              It should not (unless there is some environment flag or something
              which affects this that I am unaware of).

              Please reply to my last post in order for me to get a chance to
              understand what is going wrong. You should also temporarily move your
              .vimrc/.gvimrc/.vim out of the way and try again to make sure they are
              not interfering.

              Are you using Terminal.app or something else? If something else, does
              it make a difference if you use Terminal.app instead?

              Thanks,
              Björn

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_mac" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • pperalta@gmail.com
              ... Hi Björn, I am running on OS X 10.5.6, and I see similar behavior. When launching mvim from an iTerm window, it defaults to the dark background. When
              Message 6 of 12 , Apr 30, 2009
              • 0 Attachment
                > Please reply to my last post in order for me to get a chance to
                > understand what is going wrong.  You should also temporarily move your
                > .vimrc/.gvimrc/.vim out of the way and try again to make sure they are
                > not interfering.

                Hi Björn,

                I am running on OS X 10.5.6, and I see similar behavior. When
                launching mvim from an iTerm window, it defaults to the dark
                background. When launching from Terminal, it defaults to the white.
                I am able to reproduce this even when removing .viminfo before
                launching.

                Thanks,
                Patrick

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_mac" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • björn
                ... Thanks Patrick, The problem seems to be that iTerm sets the environment variable COLORFGBG which Vim picks up on and changes background to dark
                Message 7 of 12 , May 1 5:02 AM
                • 0 Attachment
                  2009/4/30 pperalta@... <pperalta@...>:
                  >
                  >> Please reply to my last post in order for me to get a chance to
                  >> understand what is going wrong.  You should also temporarily move your
                  >> .vimrc/.gvimrc/.vim out of the way and try again to make sure they are
                  >> not interfering.
                  >
                  > Hi Björn,
                  >
                  > I am running on OS X 10.5.6, and I see similar behavior.  When
                  > launching mvim from an iTerm window, it defaults to the dark
                  > background.  When launching from Terminal, it defaults to the white.
                  > I am able to reproduce this even when removing .viminfo before
                  > launching.

                  Thanks Patrick,

                  The problem seems to be that iTerm sets the environment variable
                  "COLORFGBG" which Vim picks up on and changes 'background' to "dark"
                  automatically (Terminal does not set that variable). It is possible
                  to work around this issue by resetting that variable before launching
                  MacVim, e.g.:

                  export COLORFGBG=

                  I won't do anything about this, since it apparently is a "feature" of
                  Vim (just like the feature where Vim will take on the dimensions of
                  the terminal window you launched it from, even when using a GUI [which
                  I find kind of weird]).

                  Björn

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_mac" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • pperalta@gmail.com
                  Hi Björn, Thanks for the tip. However setting this variable with iTerm doesn t seem to make a difference. In fact when I launch a new iTerm window I tried
                  Message 8 of 12 , May 1 5:57 AM
                  • 0 Attachment
                    Hi Björn,

                    Thanks for the tip. However setting this variable with iTerm doesn't
                    seem to make a difference. In fact when I launch a new iTerm window I
                    tried this:

                    echo $COLORFGBG

                    which didn't return anything. I'll dig around through the iTerm
                    settings to see if this is implicitly set somewhere else. Or am I
                    doing something wrong?

                    Thanks for your help!
                    -Patrick
                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_mac" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • björn
                    ... How odd. That variable is definitely the problem over here. Try the following: 1. run mvim from iTerm, type :!export when it starts 2. do the same
                    Message 9 of 12 , May 1 6:49 AM
                    • 0 Attachment
                      >
                      > Thanks for the tip.  However setting this variable with iTerm doesn't
                      > seem to make a difference.  In fact when I launch a new iTerm window I
                      > tried this:
                      >
                      > echo $COLORFGBG
                      >
                      > which didn't return anything.  I'll dig around through the iTerm
                      > settings to see if this is implicitly set somewhere else.  Or am I
                      > doing something wrong?

                      How odd. That variable is definitely the problem over here. Try the following:

                      1. run "mvim" from iTerm, type ":!export" when it starts
                      2. do the same from Terminal.app

                      Look for any differences in the output. For me they are the same,
                      except the instance started from iTerm will have the following
                      additional entry

                      declare -x COLORFGBG="7;0"

                      Can you spot any differences?

                      Also, I have modified the "Default" bookmark in iTerm so that
                      "Display" is set to "Dark Background" (to get a dark instead of white
                      background...with the [default] white background the above variable is
                      set to "0;15").

                      Björn

                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_mac" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • pperalta@gmail.com
                      Hi Björn, I saved the output and did a diff: $ diff terminal.txt iterm.txt 12c12
                      Message 10 of 12 , May 1 12:08 PM
                      • 0 Attachment
                        Hi Björn,

                        I saved the output and did a diff:

                        $ diff terminal.txt iterm.txt
                        12c12
                        < declare -x LANG="en_US.UTF-8"
                        ---
                        > declare -x LANG="en_US"
                        30,31c30
                        < declare -x TERM_PROGRAM="Apple_Terminal"
                        < declare -x TERM_PROGRAM_VERSION="240"
                        ---
                        > declare -x TERM_PROGRAM="iTerm.app"

                        Changing the default bookmark to a dark background doesn't seem to
                        make a difference for me (how odd!).

                        Let me know if you'd like for me to try anything else.

                        Thanks!
                        Patrick
                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_mac" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      • björn
                        ... Hmmm. I seem to recall that Vim tries to guess if the background of the terminal window is dark or light on launch. I am guessing that for some reason
                        Message 11 of 12 , May 1 1:46 PM
                        • 0 Attachment
                          > I saved the output and did a diff:
                          >
                          > $ diff terminal.txt iterm.txt
                          > 12c12
                          > < declare -x LANG="en_US.UTF-8"
                          > ---
                          >> declare -x LANG="en_US"
                          > 30,31c30
                          > < declare -x TERM_PROGRAM="Apple_Terminal"
                          > < declare -x TERM_PROGRAM_VERSION="240"
                          > ---
                          >> declare -x TERM_PROGRAM="iTerm.app"
                          >
                          > Changing the default bookmark to a dark background doesn't seem to
                          > make a difference for me (how odd!).

                          Hmmm. I seem to recall that Vim tries to "guess" if the background of
                          the terminal window is dark or light on launch. I am guessing that
                          for some reason it always guesses "dark" in your case. I'll have to
                          take a look at the source code in order to understand what is going on
                          but since this is not exactly a critical bug I'll do it later (it
                          would be very helpful if you could try to take a look at this yourself
                          since my terminal "behaves" so it may be harder for me to figure out
                          where things go wrong).

                          For now adding "set bg=light" or "set bg=dark" to ~/.gvimrc is the
                          recommended workaround.

                          Björn

                          --~--~---------~--~----~------------~-------~--~----~
                          You received this message from the "vim_mac" maillist.
                          For more information, visit http://www.vim.org/maillist.php
                          -~----------~----~----~----~------~----~------~--~---
                        • Patrick Peralta
                          Hi Björn, The workaround works as advertised. Thanks again, and let me know if you want me to try anything else in a future release. -Patrick ... -- Patrick
                          Message 12 of 12 , May 5 5:39 AM
                          • 0 Attachment
                            Hi Björn,

                            The workaround works as advertised. Thanks again, and let me know if you want me to try anything else in a future release.

                            -Patrick

                            On Fri, May 1, 2009 at 4:46 PM, björn <bjorn.winckler@...> wrote:

                            > I saved the output and did a diff:
                            >
                            > $ diff terminal.txt iterm.txt
                            > 12c12
                            > < declare -x LANG="en_US.UTF-8"
                            > ---
                            >> declare -x LANG="en_US"
                            > 30,31c30
                            > < declare -x TERM_PROGRAM="Apple_Terminal"
                            > < declare -x TERM_PROGRAM_VERSION="240"
                            > ---
                            >> declare -x TERM_PROGRAM="iTerm.app"
                            >
                            > Changing the default bookmark to a dark background doesn't seem to
                            > make a difference for me (how odd!).

                            Hmmm.  I seem to recall that Vim tries to "guess" if the background of
                            the terminal window is dark or light on launch.  I am guessing that
                            for some reason it always guesses "dark" in your case.  I'll have to
                            take a look at the source code in order to understand what is going on
                            but since this is not exactly a critical bug I'll do it later (it
                            would be very helpful if you could try to take a look at this yourself
                            since my terminal "behaves" so it may be harder for me to figure out
                            where things go wrong).

                            For now adding "set bg=light" or "set bg=dark" to ~/.gvimrc is the
                            recommended workaround.

                            Björn





                            --
                            Patrick Peralta
                            http://www.blackbeanbag.net

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

                          Your message has been successfully submitted and would be delivered to recipients shortly.