I am trying to set up vim to behave consistently between my Yosemite installation and another Ubuntu 14 system that I have. The main problem I'm having is with background color highlighting. The desired look is below, from gnome-terminal on Ubuntu:
However, when I try to set up the same theme in OSX using iTerm (or terminal.app) I lose the highlighting as vim seems to match the color background to the highlighting background:
Any idea of what I might be doing wrong or some commands I can use to probe how to modify the background color in Macvim so that there is consistency between both interfaces?
Add set t_Co=8 just before the line colorscheme solarized
Typically in Vim, people will have to set t_Co=256 to get rid of the background highlighting you're referring to. However, it seems that MacVim automatically assumes 256 colors, a result of the GUI.
Through set t_Co=8, you'll be overriding that default setting.
In theory anyways?
Related
I am currently trying to configure my Neovim and Terminal setup in MacOS. One of the things I am doing is using Pywal to generate colorschemes in sync with my wallpaper. I am having one problem. When I run wal -i "path/to/image.jpg", my cursor/caret is becoming a color that I do not want it to become (it ends up becoming a dark color and I have a hard time seeing it against the background of the terminal, so I would like to change it to a lighter color).
So i was wondering what I should configure in order to change the cursor/caret. I already tried changing the cursor color on the iterm2 itself, it does not work when pywal is running but works fine when I do not have a colorscheme generated by pywal. I have tried using wpgtk as well but I am not sure how to configure it to change the cursor color.
So any help on how to change my cursor color while running pywal is what I need.
Also, when I use AlphaTechnology's pywal.nvim plugin for Neovim written in Lua, which essentially just uses pywal generated colorscheme for Neovim, the cursor is remains white. The cursor only becomes a problem when I change the terminal's colorscheme to something decided by wal -i "path/to/image.jpg" where I get problems with the cursor.
Switching from Vim (on VSCode) to nvim on my Mac, I'm trying to change some color schemes.
However, when I change with :colorscheme <color>, the changes in the window don't reflect what they should.
I originally found this error while trying to load a separate color scheme from github and it didn't work, then tried others and builtin ones and they all are wrong:
Choosing a scheme:
After chosen:
It seems all these default schemes are derivative of green highlight on white text on black background.
I figured it probably has something to do with Terminal preferences, but couldn't find any solutions.
Thanks!
So you are using the builtin terminal of macOS? If that is the case, probably because the builtin terminal does not support true colors. Get yourself a decent terminal emulator, like, kitty terminal, wezterm, iterm2.
Add the following to your config:
set termguicolors
Install a color scheme supporting true color, like gruvbox-material.
Switch to it colorsheme gruvbox-material. It should work.
I'm a fresh vim user, and I want to try new color themes.
I created a .vim dir which contains colors dir with themes and .vimrc file, and I created a symlink in my home dir, it is points to ./vim/.vimrc file.
Here is my .vimrc:
syntax enable
set t_Co=256
set synmaxcol=240
set background=dark
colorscheme twilight
let g:solarized_termcolors=256
This is the screenshot:
and that's what I want:
Whats wrong?
Note:
If I use the graphical macvim, it works, so something wrong with in my terminal
The let g:solarized_termcolors=256 is only useful if you use the solarized colorscheme. Since you want to use twilight, this line is useless and should be removed.
The twilight theme is GUI-only. Its colors are defined with hex values which are only understood by MacVim/GVim. It won't work in the terminal, no matter what you do. You can use twilight256 instead, which is designed for color terminals.
The vim themes, define a separate set of colors for the GUI (i.e. gvim) and the terminal (i.e. vim), hence you might end up seeing different colors in gvim vs vim. The reason behind that is the limited number of colors supported in the terminal compared to GUI.
CSApprox
But you could use a plugin like CSApprox, which will convert the colors in the GUI colorscheme to an equivalent one for terminal such that you see almost the similar set of colors. Most modern terminals (like Gnome Terminal, Console, OSX Terminal) that support 88 or 256 colors should work fine with this plugin.
The good thing about the CSApprox plugin is not separate configuration is necessary, and merely having this plugin in your .vim directory is good enough. And when you run the colorscheme command to choose a color scheme, this plugin automatically converts the colors for you as long as your terminal supports 88 or 256 colors.
And if you're running gvim or the terminal does not support 88/256 colors, this plugin just merely remains silent without doing any color conversions. And there is a mechanism to export the converted colors too I believe.
Alternative
Another similar plugin that I've heard is guicolorscheme which is similar to CSApprox, but you need to set the color scheme using the command :GuiColorScheme <color scheme name>.
I am having a strange issue with iTerm2, in terminal vim (non-gui) and the solarized color scheme. First, I have set iTerm2 to use the dark solarized colour scheme.
I am also using solarized for vim. I have the following lines in my .vimrc
set background=dark
colorscheme solarized
In the terminal the color scheme looks incorrect:
For reference this is how it looks under MacVim (gui vim)
What do I need to change in iTerm or my .vimrc to get the colors looking correctly in my console vim?
A couple of things to check:
In iTerm2, in Preferences -> Profiles -> Terminal, under "Terminal Emulation" you have "Report Terminal Type:" set to xterm-256color.
In your .vimrc, there are some options you can also set to make sure it's using 256 colors:
set background=dark
" solarized options
let g:solarized_visibility = "high"
let g:solarized_contrast = "high"
colorscheme solarized
And one of those should work, but #1 first.
BUT, if you're using the default, built in vim on Snow Leopard, it won't work, as it's not built with support for 256 colors. I believe the built in version in Lion does.
Edit: Based on several comments on this answer, I've removed let g:solarized_termcolors = 256 line from the .vimrc example above. It appears that could be a problem for some. Another says that adding the line let g:solarized_termcolors = 16 fixed a color display problem. Your own mileage may vary.
Second Edit: If you've loaded the solarized color palette into iTerm2, then you must let g:solarized_termcolors=16. Only let g:solarized_termcolors=256 if you are not using the solarized palette as your iTerm2 color preset.
The above answers didn't work for me.
I'm using iTerm2 with vim 7.3 on OS X 10.7.4.
If the above solutions didn't work for you too, try this
syntax on
set background=dark
let g:solarized_termtrans = 1
colorscheme solarized
Update: According to Jim Stewart, this works on Kitty too.
https://github.com/altercation/solarized/tree/master/iterm2-colors-solarized
Download Solarized package (https://github.com/altercation/solarized) and follow instructions:
Open iTerm 2, open Preferences, click on the "Profiles" (formerly Addresses, formerly Bookmarks) icon in the preferences toolbar, then select the "colors" tab. Click on the "load presets" and select "import...". Select the Solarized Light or Dark theme file.
You have now loaded the Solarized color presets into iTerm 2, but
haven't yet applied them. To apply them, simply select an existing
profile from the profile list window on the left, or create a new
profile. Then select the Solarized Dark or Solarized Light preset from
the "Load Presets" drop down.
====================================
Or:
cd ~/.vim/bundle
git clone git://github.com/altercation/vim-colors-solarized.git
Modify .vimrc
Dark Theme:
syntax enable
set background=dark
colorscheme solarized
Light
syntax enable
set background=light
colorscheme solarized
This worked for me in OS X 10.9.1 in iTerm 2 as well as Terminal. One mistake I was making was putting the colorscheme declaration before the termtrans and termcolors settings (and I needed both of these to make it work). As others have said, I set my terminal type to xterm-256color
if !has("gui_running")
let g:solarized_termtrans=1
let g:solarized_termcolors=256
endif
colorscheme solarized
set background=dark
From the creator: http://ethanschoonover.com/solarized/vim-colors-solarized
IMPORTANT NOTE FOR TERMINAL USERS:
If you are going to use Solarized in Terminal mode (i.e. not in a GUI version like gvim or macvim), please please please consider setting your terminal emulator’s colorscheme to used the Solarized palette. I’ve included palettes for some popular terminal emulator as well as Xdefaults in the official Solarized download available from Solarized homepage. If you use Solarized without these colors, Solarized will need to be told to degrade its colorscheme to a set compatible with the limited 256 terminal palette (whereas by using the terminal’s 16 ansi color values, you can set the correct, specific values for the Solarized palette).
If you do use the custom terminal colors, solarized.vim should work out of the box for you. If you are using a terminal emulator that supports 256 colors and don’t want to use the custom Solarized terminal colors, you will need to use the degraded 256 colorscheme. To do so, simply add the following line before the colorschem solarized line:
let g:solarized_termcolors=256
Again, I recommend just changing your terminal colors to Solarized values either manually or via one of the many terminal schemes available for import.
I struggled with the same problem on OSX 10.11.6, iTerm2 Build 3.0.12.
Here is my fix for it.
.vimrc
syntax enable
set background=dark
colorscheme solarized
Set Report Terminal Type to xterm-256color.
Set color preset in the profile to Solarized Dark
Bill Turner's answer works, but there is a way to get the colors to match MacVim exactly. Solarized has support specifically for iTerm2, among other terminal emulators.
Go to the iterm2-colors-solarized github page
Follow the instructions under "Installation"
Make sure your .vimrc has the line colorscheme solarized
This should set the vim colors in iTerm2 to be exactly as they are in gui editors.
A simple way to solve this problem is:
In colors dir on vim-color-solarized exist an arquive named 'solarozed.vim'
Open this file and search:
exe "let s:bg_back = ' ".s:vmode."bg=".s:back ."'"
replace to:
exe "let s:bg_back = ' ".s:vmode."bg=".s:none ."'"
For any still having issues like I was, I had installed iterm2 solarized color profile. Installing vim-color-solarized to vim bundles and following the instructions was unnecessary and was incompatible. There were funny highlighting issues like in the screen capture above.
Lesson learned: don't do both.
I tried all of the previous suggestions. I just added set t_Co=256 to .vimrc and it was fixed. I didn't need to create a tmux alias or change my config file.
None of the previous answers worked for me. Apparently I was missing:
set termguicolors
Here's what I did:
cp ~/.vim/colors/ir_black.vim /usr/share/vim/vim72/colors/
Then tried to open some code and :colorscheme ir_black
It changes a few colors but makes most of the text start to blink with the cursor.
It happens with almost all the other custom colorschemes as well. Does anyone have any ideas of what might be wrong?
I added t_Co=256 to my .vimrc file and it didn't seem to help.
PS: I'm on a Mac OS X.
Set your TERM to xterm-256color. Follow up on the iterm2 mailing list if that still doesn't work.
Edit : I found an exact duplicate of your question :here. It seems to be an issue with iTerm not supporting 256 colors by default.
The usual problem with color scheme and terminal is that terminal are often limited to 256 colors, and GUI color scheme are using 2^32 colors. So some of them are not correctly rendered in terminal.
There is a simple test to check: if you are lauching the GUI version is the color scheme rendered correctly ?
The possible solution are :
1. Convert your color scheme to 256 colors using the following plugin : CSApprox.vim
2. Choose a different color scheme. (Often on Vim.org color schemes compatible with Terminal have "256" in their name, like "wombat256" for example)
3. Use a GUI version like MacVim or GVim
If I remember correctly, the color sheme Zenburn is working nicely with both GUI and terminal version. It is rather dark with pastel colors.
Personal story : after spending ages to fiddle with color scheme to get something right for terminal, I switched to the GUI version. The GUI version with the icon bar hidden is not really different to terminal version anyway, as long as you are working locally
the default vim binary in /usr/bin/ will not work with any terminal. you need to have a version that supports gui - type "echo has('gui')" in vim command mode to check.
so your only option is to use a gui one (macvim etc.), or compile it with athena, gtk or x11 with macports, but i would advise against the latter, because it pulls down a shitload of dependencies.
i think it's better to use macvim for serious development that needs syntax highlighting, and use the 16 colour version in the terminal for quick edits.