巨蟒的 vim 语法突显

如何在 Vim 7中为 python 设置语法突显?

我想设置自己的配色方案,并为一种类型的代码文件设置语法突显。

123335 次浏览

Put the line syntax on in your .vimrc.

The command to enable syntax highlighting in vim is :syntax on, if you want it to be active everytime you launch vim, just add a line containing syntax on in your .vimrc file.

  1. Verify that you have the latest version of vim, equally execute sudo apt-get install vim
  2. Modify the .vimrc file with the instruction echo "syntax on" >> ~/.vimrc
  3. Open the file with vi app.py. You will see the Syntax highlighting

enter image description here

If you're on *nix system (linux, macos) or cygwin and if you already have vim :set syntax set but your filename doesn't end with .py you can add a shebang to the first line of your file:

#!/usr/bin/env python

Next time you open the file in vim, you should see syntax highlighting. Note this will work for other file types, you just use the interpreter name i.e. (python, ruby, sh)