zsh function for editing Django project in a single vim

by Jeremy Jones

When I'm working on a Django project, I typically open all of my python files (settings.py, urls.py, views.py and models.py) in a single vim instance. All of my projects to date have been simple and only have a single app. When I start working, I fire up a terminal session and type:

vim urls.py settings.py {{app}}/views.py {{app}}/models.py

Being the lazy type, I just created a zsh function to do that for me:

djvim() {
vim settings.py urls.py ${1}/views.py ${1}/models.py ${1}/templates/*html

Now, all I have to type is "djvim {{app}}". This will also grab all of my htmlish files, which I usually have on a separate virtual desktop altogether (obviously in a separate vim instance), but I'm going to try this approach and see if I like having everything all together. But the main point is less typing to start working on a Django app, which is a good thing.


Joshua Bloom
2006-08-23 08:09:16
Hey Jeremy, I develop on a windows box and use a great little floating command line tool called slick run. When its time to work on a Django project I type DJProjectName and slick run, starts my editor, loads all the needed py files, starts the Django server, fires up a webbrowser with multiple tabs (development app, prod app, Django Documentation, admin interface, basecamp page for app in question.)

The only thing left for me to do is to choose my music and start coding.

I like your blog thanks for keeping me up to date on things pythonic.


Jeremy Jones
2006-08-23 08:57:23
Doh! You've got me beat! That'd be cool to open a gnome terminal on desktop 3 (where I have my browser), start the server, open a gnome terminal on desktop 6 (where I do my coding) and edit all my files. Maybe I'll look into that. Thanks!
anjan bacchu
2006-08-23 11:30:33
hi joshua,

I had heard about slickrun from scott hanselman at Portland CodeCamp. He has a nice blog with more cool tools :-)

I'm a windows power user but only now installed slickrun -- can you give some info on how you setup what you mentioned above ?

thank you,


Kevin Old
2006-08-23 18:44:45
Hi Jeremy. I'm a vim power user, but can't seem to figure out how you "get around" with opening multiple files. I'm able to call up 4 files with "vim file1 file2 file3", but navigating between them via :n is all I can seem to do. Have you enable tabs in your .vimrc and that's how they come up in your instance of vim? Just wondering how you're getting around between the files. Having been a vim user since 1998 and working with it daily since then, this proves that there's *always* something new to learn about vim!


Jeremy Jones
2006-08-24 11:31:32

Basically, I just map Ctrl-n to next buffer (:bn) and Ctrl-p to previous buffer (:bp) like this:

map <C-N> <ESC>:bn <CR>
map <C-P> <ESC>:bp <CR>

There are some plugins that allow you to view all the files you have open, like winmanager/wintagexplorer/winfileexplorer. I see these in my .vim/plugin directory and don't really recall which does what, but I honestly rarely use them. I can cycle pretty quickly through my open files with repeated strikes of Ctrl-n.

Joshua Bloom
2006-08-24 15:43:42

To use slickrun to make multiple things happen, you first create the individual keywords for the discrete things you want to happen. For instance if I'm doing a project for Guido, lets call it "mergeDjangoAndTurboGears"
I'd create a new magic word called mergeDjangoAndTurboGears and for the filename you put @multi@
Then in the parameters field you put all the other keywords you've already created separated by @. Example:

A little more info on @multi@