How to install python syntax support for Vim on Mac OSX?


Question

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!

1
12
1/10/2011 10:56:41 PM

Accepted Answer

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 :)

26
1/11/2011 6:49:33 PM

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.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon