Context Navigation

Using Vim with Django

This page is intended to be used as a collection of hints for using the Vim editor with Django.

Tips:

Vim Modeline

Plugins:

snippetsEmu

xml.vim

Project

Vim/IDE:

PIDA

Suggestions:

Django Project Manager

Tips

Vim Modeline

To insure that all developers are using a standard tab format (as long as they are using Vim), you can add a Vim modeline (special comment) to your files, to set people in the same mode for that file. Example:

Plugins

snippetsEmu

Development takes place on ​Google Code, where the subversion repository includes predefined snippets for django/python/etc.

​SnippetsEmu allows one to define abbreviations which can be expanded into larger blocks of text. The abbreviations can also contain place markers which can be 'jumped to' in a similar manner to the macros defined in TextMate on OS X.

One can add specific abbreviations for models or templates based on file contents. Adding the following line to your ~/.vim/after/ftplugin/python.vim file (create it if you don't have it) will allow you to define abbreviations just for models (use the file \Program Files\vim\vimfiles\after\ftplugin\python.vim under Windows):

The following is an example collection of Django specific abbreviations for use with the plugin. More examples can be found in the ​subversion repository. Please email the author with any of your own additions (f dot ingram dot lists at gmail dot com):

Such a structure can also be created by using the build in '\C' command which will recurse through the whole directory tree.

Vim/IDE

PIDA

Although this is not Django-specific (I don't think some of the other stuff in here is very Django-specific either), ​PIDA looks like a pretty nice IDE environment for VIM+Python, which would therefore help you out in Django :).

Suggestions

Django Project Manager: By panosl

The idea is to create a plugin, that will wrap the functionality of django-admin (and if it's useful manage.py) along with project.vim.

This will one to create a new django project from within vim, and generating a Project file with all the files pre-specified. This could be extended to allow, the creation of apps within the project, leveraging the usage of manage.py.

So a regular session would be:

:djsp [projectname]

This will in turn generate the required Project file with all the files of the project.

:djsa [appname]

This will create a new app, and update the Project file with the new data regarding the application.

At this point, this is enough, even though we could still wrap a bit more of django-admin/manage, by allowing inner commands to launch/stop the test server and similar additions.

In my opinion this would help with django development and help focus more on the development that usually happens within the editor, which in our case, is ofcourse (G)Vim.