A better syntax highlighting color scheme for Ruby code on Vim?

I've been migrating to Vim recently. It has impressive Ruby/Rails
support: indentation, intellisense for Ruby and Rails objects, a lot
of shortcuts for fast editing of Rails projects... you can even script
Vim in Ruby!

Vim also has good syntax-highlighting support. Unfortunately, the
color scheme applied through the syntax highlighting sucks. It lumps
together too many elements:

Methods, symbols, constants, class variables, instance variables,
global variables, block parameters, predefined constants and variables

···

--

All those are colored blue. Which completely defeats the purpose of
syntax-highlighting, to help you visually differentiate between the
various syntactical elements of the code.

Apparently, all the above (and several others) *are* differentiated
by the Vim Ruby syntax parser. However, the default color scheme
colors them all the same. So the problem is with the color scheme.

How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

--
-Alder

Alder Green wrote:

/ ...

How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

Options:

1. Get the Vim source and edit the syntax coloring engine datafiles.

2. Change editors. Kate (and KWrite) on Linux have acceptable Ruby syntax
coloring. See this page for an example:

http://www.arachnoid.com/ruby/rbeautify.rb.html

(colors exported from KWrite)

Or are these colors also too much the same for your requirements?

···

--
Paul Lutus
http://www.arachnoid.com

I think there are set of schemes in your directory version of
/usr/share/vim/vim64/colors which you can set with:
colorscheme <filename without .vim>

Also - if you like vim - you may even like it even more if you haven't
allready disovered mru and Tlist with ctags?

Cheers,

Piers Harding.

···

On Sat, Sep 02, 2006 at 06:34:37PM +0900, Alder Green wrote:

I've been migrating to Vim recently. It has impressive Ruby/Rails
support: indentation, intellisense for Ruby and Rails objects, a lot
of shortcuts for fast editing of Rails projects... you can even script
Vim in Ruby!

Vim also has good syntax-highlighting support. Unfortunately, the
color scheme applied through the syntax highlighting sucks. It lumps
together too many elements:

Methods, symbols, constants, class variables, instance variables,
global variables, block parameters, predefined constants and variables
--

All those are colored blue. Which completely defeats the purpose of
syntax-highlighting, to help you visually differentiate between the
various syntactical elements of the code.

Apparently, all the above (and several others) *are* differentiated
by the Vim Ruby syntax parser. However, the default color scheme
colors them all the same. So the problem is with the color scheme.

How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

--
-Alder

--
Home - http://www.piersharding.com
xmpp:piers@ompka.net

Hello

I use the default vim syntax highlighting which links all language
specific elements to the generic elements (ie it would link
rubyComment to comment or somesuch), and wit darkgreen background the
vim theme elflord works quite well for me. It could use some tweaking
but I am too lazy to do that.

Thanks

Michal

···

On 9/2/06, Alder Green <alder.green@gmail.com> wrote:

I've been migrating to Vim recently. It has impressive Ruby/Rails
support: indentation, intellisense for Ruby and Rails objects, a lot
of shortcuts for fast editing of Rails projects... you can even script
Vim in Ruby!

Vim also has good syntax-highlighting support. Unfortunately, the
color scheme applied through the syntax highlighting sucks. It lumps
together too many elements:

Methods, symbols, constants, class variables, instance variables,
global variables, block parameters, predefined constants and variables
--

All those are colored blue. Which completely defeats the purpose of
syntax-highlighting, to help you visually differentiate between the
various syntactical elements of the code.

Apparently, all the above (and several others) *are* differentiated
by the Vim Ruby syntax parser. However, the default color scheme
colors them all the same. So the problem is with the color scheme.

How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

Alder Green wrote:

I've been migrating to Vim recently...

<elided />

How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

You can just mess with the colour definitions. I use a
theme slightly modified from zenburn.vim:

http://pastie.caboo.se/11369

Looks like this:

http://img482.imageshack.us/img482/5025/zenbruezq7.png

···

--
Posted via http://www.ruby-forum.com/\.

Alder Green wrote:

How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

See if this helps:

http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-java.html

···

--
James Britt

http://www.ruby-doc.org - Ruby Help & Documentation
http://www.artima.com/rubycs/ - The Journal By & For Rubyists
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys

I assume you're using gvim (which is GTK-based, rather than plain vim).

As James B. recommended: http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/

"zenburn" is very nice if you like dark backgrounds.

As the install instructions indicate, to install colorschemes, create
a ~/.vim/colors directory and put the .vim files in there. Then add

colorscheme zenburn

to your ~/.vimrc file. Finally, restart gvim.

I don't use vim anymore (switched to Emacs recently), but [my
notes][1] indicate that I preferred zenburn with the following change:

hi LineNr guifg=#4f4f4f guibg=#3a3a3a
hi Normal guifg=#dcdccc guibg=#4f4f4f
hi Statement guifg=#e3ceab guibg=#4f4f4f gui=none

[1]: http://www.simisen.com/jmg/notes/vim.html

---John

···

On 9/2/06, Alder Green <alder.green@gmail.com> wrote:

[snip]

How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

Hi Alder,

I've been migrating to Vim recently. It has impressive Ruby/Rails
support: indentation, intellisense for Ruby and Rails objects, a lot
of shortcuts for fast editing of Rails projects... you can even script
Vim in Ruby!

Vim also has good syntax-highlighting support. Unfortunately, the
color scheme applied through the syntax highlighting sucks. It lumps
together too many elements:

Methods, symbols, constants, class variables, instance variables,
global variables, block parameters, predefined constants and variables
--

All those are colored blue. Which completely defeats the purpose of
syntax-highlighting, to help you visually differentiate between the
various syntactical elements of the code.

Apparently, all the above (and several others) *are* differentiated
by the Vim Ruby syntax parser. However, the default color scheme
colors them all the same. So the problem is with the color scheme.

How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

Long post follows...

Not too sure how this will appear but here we go:

stick this in your .vimrc

map <leader>hl :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>

(thats all on one line)

Now type '\hl' without the quotes on any (key)word in a ruby file.
assuming '\' is mapped as <leader> - (the default)

You should see something like:
  hi<rubyDefine> trans<rubyDefine> lo<PreProc>
echoed on the command line.

What this is saying is that particular keyword is linked to the
highlighting for 'rubyDefine' and you can tweak that any way you want
using (for eg):
hi rubyDefine cterm=none ctermfg=#f5f5f5 ctermbg=white
(replace 'cterm' with 'gui' if you're using gvim as I do)

If you don't specifically define it as above it defaults to PreProc which
is how I have it.

Here's a list of other ruby specific keywords you can modify:

hi link rubyBoolean Boolean
hi link rubyComment Comment
hi link rubyString Constant
hi link rubyStringDelimiter Constant
" hi rubyASCIICode
" hi rubyAccess
" hi rubyAttribute
" hi rubyBeginEnd gui= guifg= guibg=
hi rubyBlock gui=none guifg=#33664D guibg=white
" hi rubyBlockArgument
" hi rubyBlockParameter
hi rubyClass gui=none guifg=grey30 guibg=white
hi rubyClassVariable gui=none guifg=#556B2F guibg=white
hi rubyConstant gui=none guifg=#DC143C guibg=white
hi rubyControl gui=none guifg=#4169E1 guibg=white
hi rubyCurlyBlock gui=none guifg=#008B8B guibg=white
" hi rubyData gui= guifg= guibg=
" hi rubyDataDirective gui= guifg= guibg=
" hi rubyDefine gui= guifg= guibg=
" hi rubyDelimEscape
" hi rubyDoBlock
" hi rubyDocumentation gui= guifg= guibg=
" hi rubyError
" hi rubyEscape
" hi rubyEval
" hi rubyException gui= guifg= guibg=
hi rubyExprSubst gui=none guifg=#FF4500 guibg=white
" hi rubyFloat
hi rubyFunction gui=none guifg=grey50 guibg=white
" hi rubyGlobalVariable gui= guifg= guibg=
" hi rubyHeredocStart
" hi rubyIdentifier gui= guifg= guibg=
" hi rubyInclude gui= guifg= guibg=
" hi rubyInstanceVariable gui= guifg= guibg=
" hi rubyInteger
" hi rubyInterpolation
hi rubyIterator gui=none guifg=#ff7f50 guibg=white
hi rubyKeyword gui=none guifg=#008B8B guibg=white
" hi rubyKeywordAsMethod
" hi rubyLocalVariableOrMethod
" hi rubyModule
" hi rubyNestedAngleBrackets
" hi rubyNestedCurlyBraces
" hi rubyNestedParentheses
" hi rubyNestedSquareBrackets
" hi rubyNoDoBlock
" hi rubyNoInterpolation
" hi rubyNumber gui= guifg= guibg=
" hi rubyOperator
" hi rubyOptDoBlock
" hi rubyOptDoLine
" hi rubyPredefinedConstant gui= guifg= guibg=
" hi rubyPredefinedIdentifier gui= guifg= guibg=
" hi rubyPredefinedVariable gui= guifg= guibg=
" hi rubyPseudoVariable
" hi rubySharpBang gui= guifg= guibg=
" hi rubySpaceError
hi rubySymbol gui=none guifg=#CD853F guibg=white
" hi rubyTodo gui= guifg= guibg=

I got this by running the highlighttest script whilst a ruby script was
loaded. Then s///g until only ruby specific keywords remained.

The above is a file I save as ruby_cols.vim in .vim/ftplugin/
As you can see I don't tweak it too much, but I will one day :wink:

You can do this for any filetype. Just remember to name it
<filetype>_xxx.vim. egs ruby_cols.vim, ruby_abs.vim, php_cols.vim etc.
(ruby_abs.vim is ruby specific abbreviations)

cheers,

···

On Sat, 02 Sep 2006 18:34:37 +0900, Alder Green wrote:

--
Mark

Alder Green wrote:

How do I get a nice color scheme that would do a better job of
visually differentiating the various Ruby-related syntactical
elements?

The wife was very enthused about the new http://www.ruby-lang.org
design and particularly the syntax highlighting here so it fell
upon me to create something as close to that as possible. I did
have to change the syntax file a bit to get better granularity
of elements. Anyway:

Syntax file:
http://journal.kittensoft.org/assets/2006/9/15/ruby.vim

Colours:
http://journal.kittensoft.org/assets/2006/9/15/rubylang.vim

It looks pretty nice. I am test-driving it myself.

···

--
Posted via http://www.ruby-forum.com/\.

Options:

1. Get the Vim source and edit the syntax coloring engine datafiles.

Actually, all you need it to redefine the color definitions for each
element. No need to delve into the Vim source; it's a pretty common
case of user customization.

2. Change editors.

Thanks for the suggestion, but I like Vim very much. The Ruby support
is very impressive - in fact it's the best I've seen so far. The
editor itself is rich and excellent, with a huge community and a vast
selection of functionality-extending scripts.

Now all I need it a few lines of decent syntax highlighting
definitions. Would take me an hour or two to do myself, but I'm sure
some hardcore Vim/Ruby fan had already done a much better job :slight_smile:

···

On 9/2/06, Paul Lutus <nospam@nosite.zzz> wrote:

--
-Alder

Alder Green wrote:
>
> How do I get a nice color scheme that would do a better job of
> visually differentiating the various Ruby-related syntactical
> elements?

See if this helps:

http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-java.html

Thanks, that link is very nice. Not sure yet if it helps with my
stated specific problem - all the Ruby syntax elements that are
undifferentiated in my current scheme may also be so in the schemes on
that website.

But thanks anyway :slight_smile:

···

On 9/2/06, James Britt <james.britt@gmail.com> wrote:

--
James Britt

http://www.ruby-doc.org - Ruby Help & Documentation
Ruby Code & Style - The Journal By & For Rubyists
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys

--
-Alder

I tried several, but finally settled on denim, which I've been using
happily for the last two years.

martin

···

On 9/3/06, John Gabriele <jmg3000@gmail.com> wrote:

I assume you're using gvim (which is GTK-based, rather than plain vim).

As James B. recommended: http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/

"zenburn" is very nice if you like dark backgrounds.

Mark Woodward wrote:

stick this in your .vimrc

Oh, yeah? Try and *make* me!

<ducking on a hot Sunday afternoon>

:slight_smile:

Here's an example of what I'm looking for:

http://www.users.on.net/~markwoodward/vim/linVim/ftplugin/ruby_cols.vim

I can't use this particular one as it is aimed at people who use black
text over white bg, whereas I use white on black.

But I'm sure there are several people here who use Vim in
light-on-dark mode to edit Ruby files, and have defined an apropriate
color set for that purpose.

-Alder

It does sound a bit harsh. Sorry about that :wink:

···

On Mon, 04 Sep 2006 11:29:41 +0900, M. Edward (Ed) Borasky wrote:

Mark Woodward wrote:

stick this in your .vimrc

Oh, yeah? Try and *make* me!

<ducking on a hot Sunday afternoon>

:slight_smile:

--
Mark

I've been using the "desert" color scheme (I may be biases as my
brother wrote it, but I like it nonetheless) for many years. This
color scheme has been included in the install for many years, and at
least recently, a decent ruby.vim syntax file is also included in the
install. So now on a new machine I can just install vim and set
colorscheme=desert in my vimrc and be good to go. Since the new
ruby.vim syntax file has been included, I've never had a problem with
undifferentiated tokens. The colorscheme does suffer from the
dark-blue comments on black background when you're in CLI vim, but the
rest of it works out fine.

Mostly, my point was that since desert has good differentiation of
tokens using the default ruby.vim syntax file, most of the others
mentioned on that page should probably do pretty well also. If they're
not, there might be something weird (or old) about your vim setup.

FWIW,

Jacob Fugal

···

On 9/3/06, Alder Green <alder.green@gmail.com> wrote:

On 9/2/06, James Britt <james.britt@gmail.com> wrote:
> Alder Green wrote:
> > How do I get a nice color scheme that would do a better job of
> > visually differentiating the various Ruby-related syntactical
> > elements?
>
> See if this helps:
>
> http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-java.html

Thanks, that link is very nice. Not sure yet if it helps with my
stated specific problem - all the Ruby syntax elements that are
undifferentiated in my current scheme may also be so in the schemes on
that website.

Alder Green wrote:

Here's an example of what I'm looking for:

http://www.users.on.net/~markwoodward/vim/linVim/ftplugin/ruby_cols.vim

I can't use this particular one as it is aimed at people who use black
text over white bg, whereas I use white on black.

But I'm sure there are several people here who use Vim in
light-on-dark mode to edit Ruby files, and have defined an apropriate
color set for that purpose.

-Alder

Wait, what are you looking for then? Someone who has done the work for
you and knew your personal tastes? Someone to take the time to
customize that for you?

Why not just edit it, since you already know how?

···

--
Posted via http://www.ruby-forum.com/\.

Alder Green wrote:

Here's an example of what I'm looking for:

http://www.users.on.net/~markwoodward/vim/linVim/ftplugin/ruby_cols.vim

I can't use this particular one as it is aimed at people who use black
text over white bg, whereas I use white on black.

Yipes. Oh well, to each his own. I gave up on white text on black background
years ago when I discovered it caused me eyestrain and headaches during
all-day programming sessions.

It should be pointed out that nearly all modern text colors presume a white
background, now that that is the norm.

···

--
Paul Lutus
http://www.arachnoid.com

Thanks Jacob, and anyone else who contributed to this thread.

After trying dozens of Vim color schemes, both popular and obscure, I
eventually picked zeburn[1], with oceandeep[2] a close second.

These two color schemes had the highest level of syntactical
differentiation out of the box (there are several other schemes on
that level, but I couldn't find any higher level). Still some place
for Ruby-specific improvements by customization, e.g. define a
different color for instance vs. class variables, which Vim actually
recognizes as two different syntactical elements: rubyInstanceVariable
vs rubyClassVarible. Vanilla zenburn and oceandeep link both highlight
groups to rubyIdentifier, thus failing to visually differentiate them.

I've spent quite a few hours coding in zenburn in the last few days,
and it is indeed easy on the eyes for long coding sessions. I've yet
to test oceandeep extensively.

-Alder

[1] http://www.vim.org/scripts/script.php?script_id=415
[2] http://www.vim.org/scripts/script.php?script_id=368

Alder Green wrote:

> Here's an example of what I'm looking for:
>
> http://www.users.on.net/~markwoodward/vim/linVim/ftplugin/ruby_cols.vim
>
> I can't use this particular one as it is aimed at people who use black
> text over white bg, whereas I use white on black.

Yipes. Oh well, to each his own. I gave up on white text on black background
years ago when I discovered it caused me eyestrain and headaches during
all-day programming sessions.

I guess white on black used to be very useful on the old screens that
had low contrast and refresh rate. Any background other than black
causes more flickering, any foreground other than white causes the
text to be harder to read because it is too dim.

But I find it much better to use dark background with lighter text.
Black is not good, I think it causes me to lose focus because there is
virtually nothing visible on most of the screen (such state also did
not exist on old screens).

It should be pointed out that nearly all modern text colors presume a white
background, now that that is the norm.

I suspect this came from word processing where black on white
resembles paper. But for screens that actually emit light I like dark
backgrounds better. I wonder how reflective screens will change this.

Thanks

Michal

···

On 9/2/06, Paul Lutus <nospam@nosite.zzz> wrote: