1

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 May 18 at 22:53
  • See also :help 'term', you'll see how it defaults to win32 on Windows... – filbranden May 18 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 May 18 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 May 19 at 2:00
  • 1
    @filbranden Yep, this seems to be the way to do it. – Mr Blue May 20 at 17:04
5

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
else
   " do other stuff here
fi
| improve this answer | |
  • 2
    I wouldnt be surprised in windows env variables were case insensitive rolls eyes – D. Ben Knoble May 19 at 13:10
  • 1
    This works! Thanks so much! It is indeed $CMDER_ROOT. – Mr Blue May 20 at 17:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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