| 1 | This page is intented to be used as a collection of hints for using the Vim editor with Django. |
| 2 | |
| 3 | == SnippetsEmu == |
| 4 | |
| 5 | The [http://www.vim.org/scripts/script.php?script_id=1318 SnippetsEmu] plugin for Django 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. |
| 6 | |
| 7 | The following is a collection of Django specific abbreviations for use with the plugin (using the default start and end tags: '<' and '>'): |
| 8 | |
| 9 | Models: |
| 10 | |
| 11 | {{{ |
| 12 | Iabbr addmodel class <>(meta.Model):<CR><><CR><CR>def __repr__(self):<CR>return "%s" % (<>,)<CR><CR>class META:<CR>admin = meta.Admin()<CR><CR> |
| 13 | Iabbr mcf meta.CharField(maxlength=<>)<CR><> |
| 14 | Iabbr mff meta.FileField(upload_to=<>)<CR><> |
| 15 | Iabbr mfpf meta.FilePathField(path=<>, match=<".*">, recursive=<False>)<CR><> |
| 16 | Iabbr mfloat meta.FloatField(max_digits=<>, decimal_places=<>)<CR><> |
| 17 | Iabbr mfk meta.ForeignKey(<>, edit_inline=<False>)<CR><> |
| 18 | Iabbr m2m meta.ManyToManyField(<>)<CR><> |
| 19 | Iabbr o2o meta.OneToOneField(<>)<CR><> |
| 20 | }}} |
| 21 | |
| 22 | Templates: |
| 23 | {{{ |
| 24 | Iabbr fore {% for <entry> in <list> %}<CR>{{ <entry>.<> }}<CR><>{% endfor %}<CR><> |
| 25 | }}} |
| 26 | |
| 27 | == XML.vim == |
| 28 | |
| 29 | The [http://www.vim.org/scripts/script.php?script_id=301 xml.vim] plugin is really useful for editing XML and HTML files. It makes tag completion easy and allows you to bounce between start and end tags. |