How to install python syntax support for Vim on Mac OSX?
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 Vi开发者_如何学JAVAm, 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!
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:
- Open a Python file with vim
- type the following command
: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.
for mac os x, the vimrc file is located in /usr/share/vim directory edit the vimdc file with any text editor. Add the syntax on to the last line of the file. Then next time you start a file you can see color. This is a system wide setting. In other linux flavor it may be located in /etc/ you can find this file by find /etc -name vimdc. The edit will affect all the users on the machine. These setting can overwritten by the $HOME/.vimrc file. In your home you may also have a .vim directory. To check that you have these, do ls -a in your home directory.
精彩评论