Changes between Version 16 and Version 17 of UsingVimWithDjango
- Timestamp:
- Oct 9, 2006, 6:10:15 AM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
UsingVimWithDjango
v16 v17 1 1 = Using Vim with Django = 2 3 2 This page is intended to be used as a collection of hints for using the Vim editor with Django. 4 3 5 == Vim Modeline == 4 * Tips: 5 * Vim Modeline 6 * Plugins: 7 * snippetsEmu 8 * xml.vim 9 * Project 10 * Vim/IDE: 11 * PIDA 12 13 14 == Tips == 15 === Vim Modeline === 6 16 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: 7 17 … … 13 23 14 24 15 == [http://www.vim.org/scripts/script.php?script_id=1318 SnippetsEmu] == 25 == Plugins == 26 === snippetsEmu === 27 Development takes place on [http://code.google.com/p/snippetsemu Google Code], where the subversion repository includes predefined snippets for django/python/etc. 16 28 17 The [http://www.vim.org/scripts/script.php?script_id=1318 SnippetsEmu] plugin for Vimallows 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.29 [http://www.vim.org/scripts/script.php?script_id=1318 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. 18 30 19 31 One can add specific abbreviations for models or templates based on file contents. Adding the following line to your ~/.vim/ftplugin/python.vim file (create it if you don't have it) will allow you to define abbreviations just for models: … … 24 36 }}} 25 37 26 The following is a collection of Django specific abbreviations for use with the plugin (using the default start and end tags: '<' and '>'): 27 38 The following is a collection of Django specific abbreviations for use with the plugin (using the default start and end tags: '<{' and '}>'): 28 39 Models: 29 30 40 {{{ 31 Iabbr addmodel class <>(models.Model):<CR><><CR><CR>def __str__(self):<CR>return "%s" % (<>,)<CR><CR>class Admin:<CR>pass<CR><CR>32 Iabbr <buffer> mcf models.CharField(maxlength=<>)<CR><>33 Iabbr <buffer> mff models.FileField(upload_to=<>)<CR><>34 Iabbr <buffer> mfpf models.FilePathField(path=<>, match="<>", recursive=<False>)<CR><>35 Iabbr <buffer> mfloat models.FloatField(max_digits=<>, decimal_places=<>)<CR><>36 Iabbr <buffer> mfk models.ForeignKey(<>, edit_inline=<False>)<CR><>37 Iabbr <buffer> m2m models.ManyToManyField(<>)<CR><>38 Iabbr <buffer> o2o models.OneToOneField(<>)<CR><>41 Snip addmodel class <{}>(models.Model):<CR><><CR><CR>def __str__(self):<CR>return "%s" % (<{}>,)<CR><CR>class Admin:<CR>pass<CR><CR> 42 Snip mcf models.CharField(maxlength=<{}>)<CR><{}> 43 Snip mff models.FileField(upload_to=<{}>)<CR><{}> 44 Snip mfpf models.FilePathField(path=<{}>, match="<{}>", recursive=<False>)<CR><{}> 45 Snip mfloat models.FloatField(max_digits=<{}>, decimal_places=<{}>)<CR><{}> 46 Snip mfk models.ForeignKey(<{}>, edit_inline=<False>)<CR><{}> 47 Snip m2m models.ManyToManyField(<{}>)<CR><{}> 48 Snip o2o models.OneToOneField(<{}>)<CR><{}> 39 49 }}} 40 50 41 51 Templates: 42 43 52 Templates should be used with different tag delimiters as they will no doubt contain (X)HTML which will confuse the plugin. Assuming start and end tags are '@': 44 53 … … 47 56 }}} 48 57 49 snippetsEmu is hosted on [http://code.google.com/p/snippetsemu Google Code], you can find the development version there, where (the SVN) includes predefined snippets for django/python/etc.50 58 51 52 == XML.vim == 53 59 === XML.vim === 54 60 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. 55 61 56 == Syntax for templates==62 === Syntax for templates === 57 63 58 64 Dave Hodder has contributed standard [http://www.vim.org/scripts/script.php?script_id=1487 Vim syntax files]. … … 73 79 }}} 74 80 75 == Project.vim ==76 81 82 === Project.vim === 77 83 The [http://www.vim.org/scripts/script.php?script_id=69 Project] plugin adds IDE file organisation functionality to Vim. 78 84 … … 111 117 Such a structure can also be created by using the build in '\C' command which will recurse through the whole directory tree. 112 118 113 == PIDA == 119 == Vim/IDE == 120 === PIDA === 114 121 115 122 Although this is not Django-specific (I don't think some of the other stuff in here is very Django-specific either), [http://pida.berlios.de PIDA] looks like a pretty nice IDE environment for VIM+Python, which would therefore help you out in Django :).