vim/terminal highlighting conditionals - vim

I am just trying to set up vim such that I get the colors I prefer.
I created a ~.vimrc file and set syntax on
I then went Terminal > Preferences > Profile > Text and have been changing the ANSI colors such that the file looks the way I want
Unfortunately I have come across the problem that conditionals (if, else, and so on) are not using any of the ANSI colors and I therefore cannot change my preferences this way.
I have been looking in the vim syntax located at /usr/share/vim/vim73/syntax to see how this is implemented. I see where these are grouped, but cannot seem to find where the colors are assigned and why I cannot overwrite just this in my preferences.
where am I able to go to find this code, and what are some of the options for customizing this
NOTE
I am on Mac Yosemite 10.10.5

There are many colorscheme available. My favourite colorscheme to highlight the keywords is gruvbox following are the steps to install.
installing pathogen
mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
installing the colorscheme gruvbox
git clone https://github.com/morhetz/gruvbox.git ~/.vim/bundle/gruvbox
add the following to your ~/.vimrc file
execute pathogen#infect()
colorscheme gruvbox
set background=dark " Setting dark mode

Related

vim colorscheme shows wrong color

I want to change my colorscheme to this: earthsong on http://daylerees.github.io/
but it changes color something srange. like this (up: molokai, down: earthsong)
I try :colorscheme earthsong in vim, it gives same result.
I using vim on mac (latest version)
I got .vim code from https://github.com/daylerees/colour-schemes/blob/master/vim/colors/earthsong.vim
Can I get some help?
The very first place to look for help with an open source project is its issue tracker if it exists.
That colorscheme only uses your terminal palette. This means that you must adjust it to the colors used in the colorscheme which don't seem to be listed anywhere else than in the colorscheme itself.
If you use Vim 8 and an up-to-date iTerm you could tell Vim to use your GUI colors in the terminal with:
set termguicolors

Vim theme light solarized doesn't work with xfce4-terminal, even with terminal theme

I'm trying to use the light solarized theme with vim and xfce4-terminal.
I installed the theme for xfce4-terminal:
cd
mkdir solarized ; cd solarized
git clone https://github.com/sgerrand/xfce4-terminal-colors-solarized.git
cp xfce4-terminal-colors-solarized/light/terminalrc ~/.config/xfce4/terminal/
Apparently it works fine. However, when I use vim, the colors are different from the expected:
Gvim presents the correct colors. Konsole (with the proper theme, from the same git repository) shows the correct colors too.
The dark theme is presented correctly if change the vim and the xfce4-terminal theme.
I tried to change TERM and t_Co, but it didn't work.
I tried to follow this answer but it remains with the incorrect colors.
The link above says that the xfce4-terminal devs have changed the syntax of terminalrc.
When I compare xfce4-terminal and konsole pallets, I see that the there are some colors different, so I think terminal isn't reading rightly the terminalrc archive. Since the terminalrc archive from git is 2 years old, it makes sense. However, I don't know how to modify to the correct colors since I don't know the correspondence between the pallets of Konsoleand Xfce.
Does anyone have a suitable archive? Does anyone want to create one and make it available via git, updating the config for other people? (presuming that it's in fact a problem with the recent syntax.)
oK got it work!
You cannot use the colors which are on git hub xfce4-terminal
For the dark you can use the one which comes with xfce-terminal (Edit->Properties->Color->Presets * Solarized (dark/light)
Important is that you go afterwards to ~/.config/xfce4/terminal/terminalrc and remove
ColorCursor=
Than edit the .vimrc with
syntax enable
set background=dark
colorscheme solarized
set t_Co=16
set background=dark works for me with light and dark terminal setting.
I have exactly the same problem.
I get the best results with this.
It is not 100% the same but looks best to me
let g:solarized_termcolors=256
syntax enable
set background=light
colorscheme solarized
set t_Co=256
Hope that helps

Ubuntu, Vim, and the solarized color palette

I'd really like to get in on all the colorful goodness of the solarized colorscheme, but I can't seem to get it configured just right.
I have the main solarized file in my .vim/colors folder, I've set my terminal profile colors to what is listed on the site, and I've added the lines
set background=dark
let g:solarized_termcolors=16
colorscheme solarized
to my .vimrc file, but Vim looks greyed out and is using a bright green color as the default. How can I do it?
Here's my recommendation for things to try:
ensure syntax on is in your .vimrc file
Check what t_Co Vim has picked up from your term emulator (a quick :echo &t_Co). If it's 8, you'll want to se t_Co=16. You might also try se t_Co=256 though without let g:solarized_termcolors=16 this will use the 256 fallback mode, which isn't quite the correct color scheme.
set t_Co=16 and let g:solarized_termcolors=16 did not work for me. This is what worked:
syntax on
let g:solarized_termcolors=256
set t_Co=256
set background=dark
colorscheme solarized
I found out how do do it from this article.
I wrote the following script to do the gnome-terminal stuff.
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_background" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "#070736364242:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#EEEEE8E8D5D5:#00002B2B3636:#CBCB4B4B1616:#58586E6E7575:#65657B7B8383:#838394949696:#6C6C7171C4C4:#9393A1A1A1A1:#FDFDF6F6E3E3"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "#00002B2B3636"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "#838394949696"
If you are trying to use Vim with solarized inside of tmux, this is the fix for your issue:
Fix solarized theme in tmux
Trying it out myself, it seems to work better without the
let g:solarized_termcolors=16
Setting it to 16, I get the bright green color you seem to describe. Maybe try leaving it at the default of 256?
This doesn't, however, perfectly mimic the colors from the screenshots (although the light version looks fairly close). I only get the colors with the screenshot if I use gVim.
I didn't use the terminal profile colors provided, however, so you may get a different result.
For the copy and paste lovers, this is how you install the solarized Vim colorscheme on Ubuntu:
sudo apt-get install wget unzip curl
cd
wget http://ethanschoonover.com/solarized/files/solarized.zip
unzip solarized.zip
mkdir .vim
mkdir .vim/colors/
mv solarized/vim-colors-solarized/colors/solarized.vim ~/.vim/colors/
cp .vimrc .vimrc.old
echo "syntax enable" > .vimrc
echo "set background=dark" >> .vimrc
echo "colorscheme solarized" >> .vimrc
curl https://raw.github.com/seebi/dircolors-solarized/master/dircolors.256dark > ~/.dircolors
source .bashrc
rm -r solarized
rm solarized.zip
And presto.
From the README (emphasis mine):
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.
Simply selecting Solarized for both "Text and Background Color" (choose light or dark) and "Palette" in Terminal → Preferences → Profiles → (select yours) → Edit → Colors worked for me on Ubuntu 16.04 (Xenial Xerus) with the included Terminal application.
Some other answers recommend choosing a 256 color palette but, as mentioned in the documentation, this gives you a degraded (and visibly worse in my opinion) color scheme.
This worked for me for exherbo
git clone https://github.com/sigurdga/gnome-terminal-colors-solarized
cd gnome-terminal-colors-solarized
sh install.sh -s dark -p <my_current_profile>
256 colors in vim may also help

Vim colorscheme change

I'm having difficulty getting my colorscheme to change. I've opened both ~/.vimrc and /usr/share/vim/vimrc and added:
colorscheme desert
...and nothing. I noticed the color schemes are here:
/usr/share/vim/vim72/colors/desert.vim (...along with a bunch or others)
which seems like the wrong place so I:
cp /usr/share/vim/vim72/colors/desert.vim ~/.vim/colors/
and still no go.
Try setting your terminal colours in your .bashrc/.bash_profile to:
export TERM=xterm-256color
& in your .vimrc
let g:"your_colourscheme"_termcolors=256
& that should stick. Bit of a kludge I know but it should work.
Saves typing
:colorscheme whatever everytime you start Vim
Custom colorschemes should go in ~/.vim/colors/, and adding the colorscheme line in your ~/.vimrc should work. So it sounds like you're doing that right.
Double-check that you don't have some other colorscheme line lower down in your vimrc or in an included config file that might be overriding it.
Also double-check that your .vimrc is being loaded as expected. One easy way to tell is by trying to load a nonexistant colorscheme name - if the line is being parsed, then you should get an error like:
E185: Cannot find color scheme foobarbaz
If your colorscheme line is being correctly parsed, you need to check if your terminal is correctly configured to display the colors.
The situation with terminals is a mess when it comes to colors and fonts. It is quite probable that your terminal emulator (gnome-terminal? kterm?) and vim aren't using the same encodings for colors, or one is partially overriding the settings of the other. When it comes to the eternal war between console apps and modern colors and font rendering, your three options are:
Side with the old school, switch to xterm or rxvt, where the colors are more likely to just work, but got help you if you want antialiased fonts.
Side with the new school, sidestep the console entirely and use gvim, where fonts and colors will likely both just work.
Get caught in the middle and forever fight with getting fonts and colors to work properly for old console programs running in new terminal emulators, i.e. gnome-terminal, kterm, etc...
apt-get install vim or yum install vim <-- need full vim vs mini vim
ls /usr/share/vim/vim ##/colors <-- ## 72 or 73, etc list color schemes
cd ~
vi .vimrc
# Add the following two lines if the don't exist
syntax on
colorscheme elflord
# replace elfloard with what ever color scheme you like
If you are using vim-tiny in Ubuntu (the default one). Try to install vim-nox, vim-gtk or vim-gnome.
make sure that you are enabling syntax with :syntax enable.
Currently, using Ubuntu and VIM 8, I did this:
Browse to your user directory:
cd ~
Create and open a .vimrc file:
vim .vimrc
Click i for insert mode.
Type the following command below to enable syntax and give a specific colorscheme. This example uses the desert colorscheme:
syntax on
colorscheme desert
Hold Shift and hit : then type wq! to save and quit the file.
You should now be able to use vi and the colorscheme you choose to edit files on your Grid.
Below the default set of colour schemes for Vim 8:
blue
darkblue
delek
desert
elflord
evening
industry
koehler
morning
murphy
pablo
peachpuff
ron
shine
slate
torte
zellner

How to set default vim colorscheme

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.

Resources