Syntax highlighting in vim for python
111,387
Solution 1
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.
Solution 2
Put the line syntax on
in your .vimrc
.
Solution 3
- Verify that you have the latest version of vim, equally execute
sudo apt-get install vim
- Modify the
.vimrc
file with the instructionecho "syntax on" >> ~/.vimrc
- Open the file with
vi app.py
. You will see the Syntax highlighting
Author by
hidroto
Updated on March 10, 2020Comments
-
hidroto about 4 years
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.
-
mdeous over 13 yearsmaybe your vim doesn't have filetype detection enabled, try adding
filetype on
to your.vimrc
or type:set filetype=python
while editing a file. -
hidroto over 13 yearsi think that vim is broken becuse :help gives E433: No tags file E149: Sorry, no help for vi_help.txt Press ENTER or type command to continue
-
mdeous over 13 yearsmaybe try reinstalling it, either with your package manager or from sources, never had these errors, can't help you for this.
-
hidroto about 13 yearsthanks anyway it may have something to do with useing "..The vim-minimal package includes a minimal version of VIM,...." according to package manager
-
SDsolar almost 7 yearsPretty hard to detect a filetype unless it reads the first line of the file. I never use extensions for commands. filetype=python seems to work.
-
D. Ben Knoble over 5 years@hidroto
vim-tiny
by default provides no help, or any of the truly powerful features of vim. -
Amy Pellegrini almost 5 yearsNone of this works for me. Tried adding
filetype on
andsyntax on
on.vimrc
, also:set filetype=python
while editing the file, and added the shebang as suggested elsewhere :( -
John over 4 years@hidroto, a tag file must be created independently of Vim. One easy option is to use a program like Exuberant Ctags, which will do it for a whole directory tree in one quick command. See the Vim docs (which are good) at vimdoc.sourceforge.net/htmldoc/usr_29.html#29.1, and vimways.org/2018/you-should-be-using-tags-in-vim.
-
Alex M.M. over 3 yearsthis is the answer for my case, tx
-
enator over 3 yearsfor noobs not knowing the location of
.vimrc
file, here you go:echo "syntax on" >> ~/.vimrc