search

Home  >  Q&A  >  body text

Code highlighting - the equal sign in vim is not highlighted

is win32, gvim, version 7.4, with python highlighting. How to highlight the equal sign? There is no problem with code highlighting. It’s just that the equal sign is not highlighted. It shouldn’t be a problem with the color theme.

Thank you for your answers, your method can be highlighted.
I don’t know what’s going on, but I can’t change the .vim file. It only works if I enter those commands in the window.
I finally figured it out. What I modified was the python.vim highlight file in the vim installation directory,
And I installed bundle and python-syntax, and the default loaded is python.vim under python-syntax,
So the modification is invalid.

世界只因有你世界只因有你2743 days ago746

reply all(3)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 16:42:20

    The poster can try this solution and write his own syntax highlighting rules:

    1. Add syntax/python.vimfiles
    2. under the .vim folder
    3. Add the following content to the file:
    syntax match pythonOperator "\v\="
    syntax match pythonOperator "\v\*\="
    syntax match pythonOperator "\v/\="
    syntax match pythonOperator "\v\+\="
    syntax match pythonOperator "\v-\="
    syntax match pythonOperator "\v\%\="
    syntax match pythonOperator "\v\&\="
    syntax match pythonOperator "\v\|\="
    syntax match pythonOperator "\v\!\="
    syntax match pythonOperator "\v\>\="
    syntax match pythonOperator "\v\<\="
    syntax match pythonOperator "\v\=\="
    syntax match pythonOperator "\v//\="
    syntax match pythonOperator "\v\^\="
    syntax match pythonOperator "\v\>\>\="
    syntax match pythonOperator "\v\<\<\="
    syntax match pythonOperator "\v\*\*\="
    
    highlight link pythonOperator SpecialChar
    

    Explanation:
    syntax match creates a syntax group called pythonOperator
    And highlight link pythonOperator SpecialChar allows the content matched by this syntax group to have the SpecialChar highlight type. highlight link pythonOperator SpecialChar让这个语法组匹配的内容都带有SpecialChar高亮类型。
    SpecialChar高亮类型是什么意思呢? 打开你的配色主题方案(一般在.vim/bundle的同名文件夹下的colors目录里),你可以看到作者对不同的高亮类型设置了不同的颜色。SpecialCharSpecialCharWhat does the highlight type mean? Open your color theme scheme (usually in the colors directory under the same name folder of .vim/bundle), you can see that the author has set different colors for different highlight types. SpecialChar is one of them.

    1. Open this test file: test.py and see if it works
    a = 1
    b = 2
    a += b
    a -= b
    a *= b
    a /= b
    a %= b
    a **= b
    a == b
    a >= b
    a <= b
    a != b
    a >>= b
    a <<= b
    a &= b
    a |= b
    a //= b
    

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-16 16:42:20

    The highlighting mentioned by the questioner is grammar color matching?
    This website can visually create vim color matching files http://bytefluent.com/vivify
    You can try it hi Operator ctermfg=red guifg=red

    reply
    0
  • 仅有的幸福

    仅有的幸福2017-05-16 16:42:20

    Depending on what code you want to highlight, you can install the corresponding plug-in according to the language.
    Or try a different color scheme.

    reply
    0
  • Cancelreply