vim (vi) colors

 

vim (vi) and Directory Colors

 

 


 

Directory Colors

If you do not like your commandline directory and file colors, tweak the .dir_colors file in your home directory.

 

VIM

The vi editor on linux boxes used vim for color schemes.

Here are the primary highlighting groups:

Name Description
Comment Comments found within a program. For example # in a UNIX shell script, or <!-- in an XML file.
Constant Includes numbers, quoted strings, and booleans
Identifier Variable identifier names
Statement Language statement, such as "if", "for", and "while"
PreProc A preprocessor, such as "#include" in C
Type A variable datatype, such as "int"
Special A special symbol, usually used for special characters like "\n" in strings
Underlined Text that should be underlined
Error Text which contains a programming language error
Normal Normal text.

Vim maintains three separate highlighting schemas for each of output devices below:

  1. Green screen terminal
  2. Color terminal
  3. Graphical user interface, such as KDE or gnome

 

 

Pre-Built VIM Files

If you can find a pre-built .vimrc that is to your liking, use that. Pre-built schemes might be found on your system. To check, do a find for \*.vim files. On my RedHat linux box, a nice collection of *.vim files can be found in:

/usr/share/vim/vim61/colors

To test them out, run:


cp /usr/share/vim/vim61/colors/filename.vim .vimrc

 

 

Rolling Your Own VIM File

To build your own .vimrc file, you can start with:

syntax on
set term=[ansi|color_xterm]

Colors are specified using :highlight or :hi:

:hi Group key=value ...

Key-value pairs specify the highlighting for various output devices:

Base Key Description
term black-and-white terminal
cterm color terminal
gui graphical interface

cterm and gui have base keys, base-namefg and base-namebg, representing the foreground and background colors:

Key Possible Values
term
cterm
gui
bold, underline, reverse, italic, none
ctermfg
ctermbg
red, yellow, green, blue, magenta, cyan, white, black, gray
guifg guibg All of the above colors, plus many more; you may also use the #rrggbb format

For example, to highlight all if then else statements with cyan:

:hi Statement ctermfg=cyan cterm=bold guifg=#00FFFF

One can put multiple key/value pairs on the same line; they will all apply to the same highlighting group.


  Home