0

I like the idea of the of editing inside the terminal and like the key bindings of Vim, but the text highlighting in my Vim is much worse than in Textmate. The comparison (textmate is first):

Textmate

Vim

Obviously Vim is much worse. I've turned on syntax highlighting in my .vimrc, and have installed python.vim (not sure if this works with python 2.7). Any suggesting on how to get it up to par would be appreciated.

Thanks

3
  • 1
    You seem to mean that vim syntax highlighting is not as fine-grained as TextMates. You might want to use those words to get help instead of annoying those who use vim. Particularly as the answer suggest that it is not true.
    – johnny
    May 31, 2011 at 9:00
  • I use vim too, it's not ment to annoy anyone. And if they are, frankly, they're over-sensitive.
    – tshauck
    May 31, 2011 at 11:47
  • 1
    Well I for one tend to get annoyed when people claim some feature is worse than another without first finding out how it works.
    – johnny
    May 31, 2011 at 12:13

1 Answer 1

4

EDIT 2:

If you edit python.vim, you'll find the following line:

syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite

That's the crucial line for you. So basically, it styles def and class with pythonStatement and anything that follows it is styled with pythonFunction. You might want to rewrite it to something like

syn keyword pythonStatement def nextgroup=pythonFunction skipwhite
syn keyword pythonStatement class nextgroup=pythonClass skipwhite

where pythonClass is either defined by you as in my edit 1 (modify as you wish) or linked to one of the many color options offered by your scheme. Do :hi to see a list and link your new color style to an existing one as

HiLink pythonClass Special

(or something else). You might have to play around a little to hit your personal sweet spot.

I would've answered this the first time had you formulated your question better and made a direct request, instead of a rant. I did not quite understand what it is that you wanted. Anyway, I'll leave my earlier answer below.


Pre Edit 2:

Have you tried to actually change the color theme to something similar to what TextMate uses? Here's some example python code in my vim with beautiful syntax highlighting.

enter image description here

Of course, individual tastes differ and what I find appealing might not be appealing for others, but before brushing off vim and igniting a flame war here, you should take a look at what other color schemes are available. Google would be a good place to start.

EDIT:

Here's a quick example that shows you how to change the highlighting. This is an example with the current theme

enter image description here

The blah in class and __blah__ are both styled by the highlighting scheme pythonFunction. So I just change it temporarily to a random color and underline it as

:hi pythonFunction cterm=underline ctermfg=217 ctermbg=16

The result is:

enter image description here

So this is just a general idea of how to do it. You should change these definitions in the color scheme file so that they'll be loaded each time. If you want __blah__ to be different from the blah in class, you'll have to look at python.vim or whatever script you're using and tweak that accordingly.

8
  • 1
    @yoda I thought Yoda used Emacs?
    – Arlen
    May 31, 2011 at 0:59
  • I'm not trying to start a flame war. Or brushing off vim, I prefer it like I said, but I just don't understand why I don't have the same verbose highlighting in both. I've also tried many different themes, with each one lacking the highlighting I'd like.
    – tshauck
    May 31, 2011 at 1:03
  • @tshauck: Simply because you don't have the same color scheme in both vim and TextMate! Either try finding one that is similar to what you currently use in TextMate or pick one from the dozens available for vim (or even better: make one!). For starters, why don't you try either jellybeans or wombat just to cool your eyes ;)
    – abcd
    May 31, 2011 at 1:06
  • @yoda, you misunderstand. It's not about the colors themselves, it's about the fact that in textmate Unit and __init__ are recognized as different and thus schemed differently. I have jellybeans on my comp and the same things still happens.
    – tshauck
    May 31, 2011 at 1:11
  • 1
    @tschauck: Oh, that's just because the theme hasn't defined it that way. You can easily modify the theme if you don't mind getting your hands dirty :) If you type :hi, you'll see a list of highlighting schemes that vim knows about. In mine, for e.g., pythonException xxx links to Exception which in turn links to Statement which has the definition term=bold ctermfg=103 guifg=#8197bf. Now you can set term=underline to get an underline, or you can edit your colorscheme.vim and define colors you like for pythonException. Similarly for other key words.
    – abcd
    May 31, 2011 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.