Custom colorscheme not working on VIM - terminal

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.

Related

Neovim color schemes fail on Mac terminal

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.

syntax colors on ipython

This is bugged me for several days and what I've found so far on the internet do not satisfy me.
I've installed ipython on two separate ubuntu boxes. The ipython prompt is different on each of the boxes.
I'm reaching the boxes through ssh via a Windows bash emulator, Cmder
This box where the config is closest to ok e.g it gives me syntax color when typing a string or else.
This is the box where the config is not what I want
Reading articles and questions, it seems that I need to add the line below in the file .bashrc in my linux account to be able to have syntax colors in ipython
export LS_COLORS = "no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:ex =00;36"
I did it but it still gives me the same grey outlook in my second box and worse, when I type a ls command in my linux box, I have this error
ls: cannot analyse the value of the environment variable LS_COLORS
Any ideas on what should I do to get color syntaxes for ipython?
Recent versions of IPython use Prompt_toolkit, which provide colors via Pygments. YOu need to pass an option to IPython to select the "theme", you'll the following.
If You issue ipython --help
--colors=<CaselessStrEnum> (InteractiveShell.colors)
Default: 'Neutral'
Choices: ['Neutral', 'NoColor', 'LightBG', 'Linux']
Set the color scheme (NoColor, Neutral, Linux, or LightBG).
meaning you can either pass the --colors flag or set the c.InteractiveShell.colors=... in your config.
You will also find the following option if you issue a In[1]: %config TerminalInteractiveShell:
TerminalInteractiveShell.highlighting_style=<Union>
Current: 'legacy'
The name or class of a Pygments style to use for syntax highlighting. To see
available styles, run `pygmentize -L styles`.
That controls the theme highlighting of IPython. (use --TerminalInteractiveShell.highlighting_style=... at the prompt , or set c.TerminalInteractiveShell.highlighting_style-... in a config file).
Keep in ind the the escape control sequences used to show color may not be compatible with all terminal emulators, and that some part of IPython (in particular tracebacks) do not respect the themes (yes we know and we are planning to fix that at some point but it's quite a bit of code to refactor).
Keep in mind also that there are 2 types of colors with ANSI code. "True color" that is to say you tell the terminal emulator the R,G,B values of a character, and "short colors". Where you tell the terminal emulator that the color of the character is one of 8 predefined colors. These 8 predefined colors depends on the terminal emulator itself and can sometime be changed from the terminal emulator preferences. See wikipedia for example of changes in colors.

Setting vim's background highlight color

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?

vim color not loaded or not working

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>.

Vim under mac does not behave as expected

I recently got a mac. I was previously working on a laptop with ubuntu and I was using vim.
I now will discuss about vim in console (iTerm2 or the default terminal) and macvim.
The problem is that some binding don't work under mac. For example I had CTRL left/right for navigating between splits, CTRL up/down to move lines or blocks of code up and down, etc. They don't work anymore.
I had a bunch of plugins (nerdtree, powerline, etc.) that now look weird. Powerline doesn't display special characters in macvim and in terminal they are question marks.
In console, nerdtree looks weird and it doesn't display the special triangle character. If I hit return to open a file selected from nerdtree, it doesn't do anything. In macvim, it works ok.
Is there any guide on how to use vim on mac? Or what is the recommended way?
Nerdtree : let g:NERDTreeDirArrows=0
Powerline : Take a look at the part of strange characters in the document https://github.com/Lokaltog/vim-powerline
Navigating within splits with Ctrl + arrows work on mine. Can you post your vimrc, or try running vim without any configuration.
Ctrl+arrows to move lines and block doesn't work on mine.
Did you check which key was sent by your terminal to vim ?
Did you tried to set it manually ?
I had similar problems with emacs, including one keybinding I'm still not able to reproduce :(
I have the exact same config on my Mac and a Windows box at work, my Ubuntu box at home and a couple of VPSes. It works exactly the same on every platform in GVim/MacVim or in plain Vim.
Unfortunately I don't use either NERDTree nor Powerline but Vdt's answer seems to have all the info needed.
Some of the behaviors you describe are custom mappings. You should show us your ~/.vimrc (the old one on linux and the new one on the Mac, if there are differences) so that we can help you make it more portable.
Also, "looks weird" means nothing: please add a screenshot or two.

Resources