close forgot it?
close
Login with password or OpenID

Vim actually seems to be quite nice for Python/Django development

In the past days there was a quite nice discussion on Editors of choice on the list, and this encouraged me to give Vim another try. This time, it seems to be rather fruitful! My vim setup is stored online at my Launchpad repo, feel free to check it out.

To get a quickstart I’ve read what plugins others have recommended on the above list discussion, and in the Django Wiki on using Vim.

Whatever plugins you use, you might find my djvim.py 1 script useful to start (g)vim ready for django development. Actually, it assumes omnicomplete as well, but I guess this is not a big requirement.

After, I have checked all the plugins and things that I could find on the two pages mentioned previously, finally decided to stay with the following:

A short description of my settings related to each of them follows.

  • Omnicomplete allows code completion in python, javascript, etc. It’s original key binding is <Ctrl-x><Ctrl-o>, instead of <Ctrl-Space> the one I’m familiar with. As a result, I’ve added

    imap <C-Space> <C-x><C-o>
    

    to my .vimrc file.

  • TagList also has some weird key bindings, and very long command names to type, so I’ve defined

    map <F4> :TlistToggle<CR>
    

    It’s worth noting that I did not manage to make TagList to automatically scan the files I open, so the djvim.py file takes care of this, and tells vim which directories to scan at startup. This is definitely not the nicest way to go, but good for a Vim novice.

Besides installing these plugins, as I am a big fan of Eclipse’s debugging with PyDev, I wrote my first Vim function to run the test suite. It is a rather simple script, and it’s extremely non-interactive, but at least it is a first step. It basically runs ./manage.py test with the given application and the settings file you set at startup, and reads the output into a new window.

After spending a short day around Vim I really enjoy it, and will try to stick with it for a while. But there are still some shortcomings in which you might be able to help me out.

  • how can I set up taglist to automatically tag the files that I open for editing?
  • have a shortcut to start the development server. As Vim is not able to handle an interactive shell, this basically means to open a terminal and run the server in there, or regularly read to output of ./manage.py runserver.
  • have shortcuts to other commands, like shell_plus
  • make my extremely powerful DJtest script able to jump to the code when there is an error/failure
  • have django.vim syntax set for every html file by default

If you have any favourite settings, tweaks that I could use, please share them with me below!

Add post to: Delicious Reddit Slashdot Digg Technorati Google
Subscribe via RSS | Comment

Comments

15.09.2009 9:38 ooo

Django snippets in your repositiory [/vim/.vim/snippets] are marked as a symlink, so its unable to download them.

28.01.2010 17:18 silver bullion

I can’t help myself but feel attracted to VIM even if I know that there are many IDE to chose from and some of them offer really nifty features. Have fun coding Python with VIM! Enjoy, everyone.

20.09.2009 18:44 Niklas

You can run commands in vim with :!command, so to run the server you could do :!./manage.py runserver > /dev/null 2>&1 &, assuming your cwd is your project directory to run the server, and you have no interest in the contents of the log output. Or if you want a complete shell available at all times, I would reccomend using a terminal emulator with support for splitting the view, like Konsole. Run vim in one view and a debugger in the other for instance. Konsole, like all kde apps, is very configurable in terms of keyboard shortcuts so just configure it to your needs (default for switching between views is shift-tab).

Comment form for «Vim actually seems to be quite nice for Python/Django development»

Required. 30 chars of fewer.

Required.

captcha image Please, enter symbols, which you see on the image