Syntax highlighting in vim for python
Question:
How do I do I set the syntax highlighting in Vim 7 for python?
I would like to set my own colorschemes, and syntax highlighting for a type of code file.
Answers:
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.
If you’re already editing a Python file and syntax highlighting wasn’t on, after enabling syntax highlighting (as above) then: :set filetype=python
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)
How do I do I set the syntax highlighting in Vim 7 for python?
I would like to set my own colorschemes, and syntax highlighting for a type of code file.
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.
If you’re already editing a Python file and syntax highlighting wasn’t on, after enabling syntax highlighting (as above) then: :set filetype=python
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)