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!
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.
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
Related
I have OSX Yosemite with iTerm2. I connect via ssh to my virtual machine with Debian 8. When I run vim all colors are messed up.
iTerm2 has xterm-256colors on.
A number of things can affect your Vim colorscheme.
Make sure iTerm has the terminal type correct. As you indicated already, you use xterm-256color.
Make sure your remote shell has a matching terminal type, which you can verify with echo $TERM. If it is not set already, configure your shell with something like
# For sh, bash, zsh, ksh
export TERM=xterm-256color
# For csh, tcsh
setenv TERM xterm-256color
If the color scheme you are trying to use assumes that 256-color support is available, you may also need to add to your .vimrc:
set t_Co=256
Lastly, color schemes can be affected by the background setting in Vim, which you can set to either dark or light. To see what it's set to,
:set background?
And to set it one way or the other in your .vimrc,
set background=dark
(or light).
I was trying to generate the ctags from vim. I use Exuberant ctags.
So the problem is that when I do :!ctags or :call system('ctags') from vim it does not work because it uses my default ctags and not the exuberant ctags.
I had similar problem in my shell which I overcame by specifying the path of exuberant first
like export PATH=/usr/bin/local/:$PATH
So here is the really weird part
When I do echo $PATH in vim it shows the correct path. But When I do :call system('which ctags')
it shows me /usr/bin/ctags and not /usr/bin/local/ctags.
I can't understand what is going on??
Though I can overcome this problem by call system('/usr/bin/local/ctags') but I was just wondering if there is something better out there.
EDIT:
I use OSX 10.9.3
:set shell? -> shell=/bin/zsh
set shellcmdflag -> shellcmdflag=-c
and I set my path in zshrc file as export PATH="/usr/local/bin:usr/local:$PATH
When you do :!command or :call system('command') Vim starts a new subshell according to the values of 'shell' and a bunch of other options listed under :help 'shell'. The 'shellcmdflag' option is important because it usually tells your shell how to start (interactive or not, login or not) which usually has an impact on what *rc files are sourced and thus if your environment variables are seen or not.
Please, update your question with these informations:
your OS
:set shell?
:set shellcmdflag?
in what *rc file did you change your PATH?
When I use vim (set number) in the .vimrc file, it works fine in the terminal, but when using tmux the line numbers just don't show.
You have to set the same $TERM for your shell and tmux. Otherwise this will cause all kinds of trouble, especially when used in connection with powerline (or vim in your case).
See: https://wiki.archlinux.org/index.php/tmux#Setting_the_correct_term
As answered by three, you have to actually set the correct $TERM for BOTH your shell and TMUX
I also had a similar problem like yours today and got it working with the following steps.
To know your current $TERM in your shell, you can use the command:
echo $TERM
for me, I got the output xterm-256color.
Then in your ~/.tmux.conf file, you can set the tmux to use xterm-256color by adding this to the file.
set -g default-terminal "xterm-256color"
and all should work fine. :)
Hope I've helped.
I'm struggling to make the Solarized colorscheme correctly working on an Ubuntu 13.10 machine inside Vim inside tmux inside the gnome-terminal.
I've started configuring gnome-terminal using the script on this repository and it displays the colors correctly. The same goes if I run Vim (with the official Solarized colorscheme) inside the terminal, without tmux.
Then I tried to configure tmux using this. It happens that when I run Vim the syntax highlight for php or javascript code is wrong or, at least, different from the one I see running Vim without tmux. I've tried also running tmux as tmux -2. The colors are different, but still the syntax highlight is not correct.
I tested it out and got it working in the following way:
Install gnome solarized colorscheme. You can get it from https://github.com/aruhier/gnome-terminal-colors-solarized.
Install solarized colorscheme for vim. You can get it from https://github.com/altercation/vim-colors-solarized. In .vimrc you should add following settings:
set t_Co=256
set background=dark
colorscheme solarized
Set correct TERM variable by adding following line to your .bashrc/.zshrc
export TERM=screen-256color-bce
Run gnome-terminal, tmux, vim and profit.
These days GNOME Terminal comes with Solarized colours built in. To use it, you need to change two settings in the profile that you're using. The obvious one is the text and background colour. You also need to set the palette to Solarized, though. You can find this setting below the one for the text and background colour. At this point, setting t_Co or g:solarized_termcolors in Vim shouldn't be necessary.
The palette is the part that I missed at first, which caused me to puzzle why the text in Vim and other applications was bright blue.
The latest upgrade of Ubuntu made my vim colorscheme unusable. I know how to set it manually (:colo evening, for example), but I want to set the default for all vim sessions. I see reference in other places to .vimrc, but the right location and syntax have eluded me thus far.
Put a colorscheme directive in your .vimrc file, for example:
colorscheme morning
See here: http://vim.wikia.com/wiki/Change_the_color_scheme
Your .vimrc file goes in your $HOME directory. In *nix, cd ~; vim .vimrc. The commands in the .vimrc are the same as you type in ex-mode in vim, only without the leading colon, so colo evening would suffice. Comments in the .vimrc are indicated with a leading double-quote.
To see an example vimrc, open $VIMRUNTIME/vimrc_example.vim from within vim
:e $VIMRUNTIME/vimrc_example.vim
It's as simple as adding a line to your ~/.vimrc:
colorscheme color_scheme_name
You can try too to put this into your ~/.vimrc file:
colorscheme Solarized
What was asked for was to set:
the 'default', not some other color profile, and
'for all vim sessions', not simply for the current user.
The default colorscheme, "for all vim sessions", is not set simply by adding a line to your ~/.vimrc, as all of the other answers here say, nor is the default set without the word 'default' being there.
So all of the other answers here, so far, get both of these wrong. (lol, how did that happen?)
The correct answer is:
Add a line to your system vim setup file in /etc/vim/ that says
colorscheme default
or using the abbreviation
colo default
but not capitalized as
colo Default
(I suggest using the full, un-abbreviated term 'colorscheme', so that when you look at this years later you'll be able to more easily figure out what that darn thing does. I would also put a comment above it like "Use default colors for vim".)
To append that correctly, first look at your /etc/vim/vimrc file.
At the bottom of mine, I see these lines which include /etc/vim/vimrc.local:
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
So you can append this line to either of these two files.
I think the best solution is to append your line to /etc/vim/vimrc.local like this:
colorscheme default
You can easily do that in bash with this line:
$ echo -e "\"Use default colors for vim:\ncolorscheme default" \
| sudo tee -a /etc/vim/vimrc.local
#
# NOTE: This doesn't work:
#
# $ sudo echo 'colorscheme default' >> /etc/vim/vimrc.local
#
# It's the same general idea, and simpler, but because sudo doesn't
# know how to handle pipes, it fails with a `Permission denied` error.
Also check that you have permission to globally read this file:
sudo chmod 644 /etc/vim/vimrc.local
With $ tail /etc/vim/vimrc.local you should now see these lines:
"Use default colors for vim:
colorscheme default
You can just use the one-liner
echo colorscheme koehler >> ~/.vimrc
and replace koehler with any other available colorscheme. Imho, all of them are better than default.
Once you’ve decided to change vim color scheme that you like, you’ll need to configure vim configuration file ~/.vimrc.
For e.g. to use the elflord color scheme just add these lines to your ~/.vimrc file:
colo elflord
For other names of color schemes you can look in /usr/share/vim/vimNN/colors
where NN - version of VIM.
Ubuntu 17.10 default doesn't have the ~/.vimrc file, we need create it and put the setting colorscheme color_scheme_name in it.
By the way, colorscheme desert is good scheme to choose.
Copy downloaded color schemes to ~/.vim/colors/Your_Color_Scheme.
Then write
colo Your_Color_Scheme
or
colorscheme Your_Color_Scheme
into your ~/.vimrc.
See this link for holokai
OS: Redhat enterprise edition
colo schema_name works fine if you are facing problems with colorscheme.