I'm currently running Vim in Windows 10. I want to specify in my config file certain settings for when I'm running Vim in Cmder, different settings when I'm running Vim in Alacritty, etc.

When in Cmder, if I run echo &term I get win32, and when I run echo $term I get cygwin. What's the difference between $term and &term, and are these the only ways I can access the name of the terminal? Are one of those correct? The shell I'm running in Cmder is cmd with Cmder's clink configurations.

  • Are you running echo $term or echo $TERM? The $ variables are the ones coming from the environment, so you should be able to find/inspect them there as well...
    – filbranden
    Commented May 18, 2020 at 22:53
  • See also :help 'term', you'll see how it defaults to win32 on Windows...
    – filbranden
    Commented May 18, 2020 at 22:54
  • @filbranden I'm running echo $term but echo $TERM gives the same thing. Is there a way to get it to recognize that I'm running Cmder?
    – Mr Blue
    Commented May 18, 2020 at 23:14
  • 1
    Perhaps there are better alternative than setting specific option for Cmder. Which settings do you want to customize for Cmder?
    – jdhao
    Commented May 19, 2020 at 2:00
  • 1
    @filbranden Yep, this seems to be the way to do it.
    – Mr Blue
    Commented May 20, 2020 at 17:04

2 Answers 2


Regarding the two variables:

  • $term is a variable from the environment. When you are on the terminal (without opening Vim), echo $term should echo the same as :echo $term from inside Vim. (I'm a little bit surprised that it is not upper case, like $TERM.)
  • &term represents the option term (see :h 'term'). So the output from :echo &term is the same as the output from :set term?.

If you need some information about the world outside of Vim you can check environment variables (like $TERM).

In both of your terminal run the command set to list all environment variables with their values and find a variable that has a different value per terminal. Or a variable that is set in one terminal, but not the other.

By just looking at the Cmder web sites I guess it could be something like this:

if $CMDER_ROOT != ''
   " do CMDER stuff here
   " do other stuff here
  • 2
    I wouldnt be surprised in windows env variables were case insensitive rolls eyes
    – D. Ben Knoble
    Commented May 19, 2020 at 13:10
  • 1
    This works! Thanks so much! It is indeed $CMDER_ROOT.
    – Mr Blue
    Commented May 20, 2020 at 17:03

In my macOS system, the unique name of the terminal program is set in environment variable TERM_PROGRAM. Apple's inbuilt Terminal, iTerm2, WezTerm return sensible unique names that correctly identify them. As of writing this, Alcritty does not set it to any value, and Kitty terminal emulator returns wrong name "Apple_Terminal".

Run echo $TERM_PROGRAM in your system to see if it works there as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.