Search code examples
vimemacscolor-scheme

Solarized differences between Vim and Emacs


I know there is already a plethora of Vim/Emacs and Solarized questions so I am a bit hesitant to add yet another, but I can't seem to find any that address this exact issue.

The problem is that the same file looks very different in Vim than it does in Emacs when both editors are setup to use the solarized-dark theme. And what I can't figure out is whether this is an issue with Solarized or just a fundamental difference between Vim and Emacs.

Here is what I am working with:

In order for Emacs to display the background color properly I have to explicitly set TERM to xterm-16color. However, the colors look exactly the same whether I am running the editors in a terminal or in their respective GUIs (gvim and emacs without the -nw flag).

Here is a screenshot with Vim on the left and Emacs on the right:

enter image description here larger version

Ultimately, I want to get the Emacs colors to look exactly like the Vim colors. Is this possible? If so, is it a matter of tweaking the Emacs version of the color scheme? Or, is this just a fundamental difference between the two editors that can't be change?


Solution

  • I don't write in Ruby, but the general way I'd approach the situation from Emacs would be this:

    • Move the point to the word that in your opinion is not painted properly, then M-xcustomize-face This will autofill the minibuffer with the name of the face under point and once you press RET will open a customization buffer, where you can change how the face is rendered. It looks like at least some of the differences can be removed that way.

    • Major editing modes usually associate a face (normally one from font-lock variety) with a certain lexical group in the target language. You would need to investigate what options and how exactly Ruby mode assigns faces to the syntax elements of the language. Probably global adjustments to the face will be too extreme (might influence other modes too), so if you could tweak Ruby mode only to associate different syntax groups with faces w/o modifying faces, it would be a preferred choice.

    • You could investigate the level of decoration. Normally language modes in Emacs use Font Lock mode to paint the text, some modes offer more or less colours, depending on the level. More info here: http://www.gnu.org/software/emacs/manual/html_node/elisp/Levels-of-Font-Lock.html

    • It is also possible that Ruby mode originally doesn't emphasize some characters you wanted to be emphasized (number signs and quotes). If this is not achievable by tweaking the association of syntax elements with faces and neither by decoration level, then you could try adding more keywords to the Font Lock mode, like described here: http://www.gnu.org/software/emacs/manual/html_node/emacs/Font-Lock.html

    • It also looks like you wanted to display whitespace characters in some way http://emacswiki.org/emacs/ShowWhiteSpace#toc7 here's some info on how to do that, it also has info about the margin to show the maximum line length.

    • You can toggle display of line numbers with M-xlinum command.

    PS. Also beware of that GUI version and terminal version may have different colouring schemes. The terminal version might use less colours overall and would usually strive for higher contrast, then the GUI one.