Can vim recognize when it is used in Console2?

烈酒焚心 提交于 2019-12-07 06:59:54

问题


With Steven Harman's Solarized tweak for Console2 I can more or less use the Solarized color scheme in win32 vim. But once in a while I find myself in vim via a vanilla cmd.exe window and the Solarized 16-color colorscheme is not aligned to it gui equivalent.

So I'd like to fix this inside my vimrc, but how can I check if console vim is being used in Console2?

Thanks!


回答1:


In Console2, you can set arbitrary environment variables by modifying the shell invocation (from the Settings dialog, or directly in the XML config). For the default Windows command prompt, use a value of:

cmd.exe /K set EMULATOR=console2

For Cygwin Bash, something like this should work:

C:\cygwin\bin\bash.exe -c "export EMULATOR=console2; exec /bin/bash -i"

Then, check for the $EMULATOR value in a conditional in your .vimrc, as outlined by romainl's answer.




回答2:


See if your terminal emulator sets an environment variable or if you can set one in one way or another.

In bash, one would do:

$ export EMULATOR=console2

With that out of the way, you can put something like this in your _vimrc:

if $EMULATOR == "console2"
  colorscheme foo
else
  colorscheme bar
endif


来源:https://stackoverflow.com/questions/13235241/can-vim-recognize-when-it-is-used-in-console2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!