I recently started programming in python and have fallen in love with Vim over the past few weeks. I know want to use Vim as my primary editor for python files. I know there are python plugins for Vim, but I am very confused as to where/how I can install these. I don't really understand where Vim is installed. I'm running the latest version of Mac OS X Snow Leopard.
Any help would be greatly appreciated. Thanks!
If you want to toggle this on/off (without creating a . vimrc file) simply type :syntax on while in vi/vim.
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. maybe your vim doesn't have filetype detection enabled, try adding filetype on to your .
The path used by macOS's default vim install is /usr/share/vim/vimrc .
Vim already comes with syntax highlighting for a huge number of programming languages that includes Python. There are three plugins that help to improve it - one is called python-syntax, the other one is python-mode, and the third one is python. vim.
To best answer your initial question: "How to install python syntax support in Vim":
There is no need to install anything! If you have not made any modifications (e.g. no configuration changes for vim in ~/.vimrc
) try the following:
:syntax on
You should now have VIM properly highlight your Python file.
To avoid having to re-type those command over and over again, I would suggest you keep a configuration file for VIM. This is usually located in your home directory, if there is not one there already, create a ~/.vimrc
file and add the syntax on
directive there to
have VIM automatically highlight your Python files.
If you need to know more about structure/installation of plugins, then Senthil's answer is better suited :)
You will find that you have a folder by name .vim
in your home directory cd ~
and it will contain the following directories
ftdetect/ ftplugin/ plugin/ syntax/
You need to download the plugins and install them (copy them) to those directories.
Apart from that, in your .vimrc file have the following lines which will enable you to write python programs following PEP8.
set autoindent
set tabstop=4
set expandtab
set shiftwidth=4
filetype indent on
There are some good documentation out there as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With