Changes between Version 16 and Version 17 of UsingVimWithDjango


Ignore:
Timestamp:
Oct 9, 2006, 6:10:15 AM (18 years ago)
Author:
panosl
Comment:

restructured stuff and added a header menu/list

Legend:

Unmodified
Added
Removed
Modified
  • UsingVimWithDjango

    v16 v17  
    11= Using Vim with Django =
    2 
    32This page is intended to be used as a collection of hints for using the Vim editor with Django.
    43
    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 ===
    616To 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:
    717
     
    1323
    1424
    15 == [http://www.vim.org/scripts/script.php?script_id=1318 SnippetsEmu] ==
     25== Plugins ==
     26=== snippetsEmu ===
     27Development takes place on [http://code.google.com/p/snippetsemu Google Code], where the subversion repository includes predefined snippets for django/python/etc.
    1628
    17 The [http://www.vim.org/scripts/script.php?script_id=1318 SnippetsEmu] plugin for Vim 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.
     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.
    1830
    1931One 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:
     
    2436}}}
    2537
    26 The following is a collection of Django specific abbreviations for use with the plugin (using the default start and end tags: '<' and '>'):
    27 
     38The following is a collection of Django specific abbreviations for use with the plugin (using the default start and end tags: '<{' and '}>'):
    2839Models:
    29 
    3040{{{
    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><>
     41Snip addmodel class <{}>(models.Model):<CR><><CR><CR>def __str__(self):<CR>return "%s" % (<{}>,)<CR><CR>class Admin:<CR>pass<CR><CR>
     42Snip mcf models.CharField(maxlength=<{}>)<CR><{}>
     43Snip mff models.FileField(upload_to=<{}>)<CR><{}>
     44Snip mfpf models.FilePathField(path=<{}>, match="<{}>", recursive=<False>)<CR><{}>
     45Snip mfloat models.FloatField(max_digits=<{}>, decimal_places=<{}>)<CR><{}>
     46Snip mfk models.ForeignKey(<{}>, edit_inline=<False>)<CR><{}>
     47Snip m2m models.ManyToManyField(<{}>)<CR><{}>
     48Snip o2o models.OneToOneField(<{}>)<CR><{}>
    3949}}}
    4050
    4151Templates:
    42 
    4352Templates 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 '@':
    4453
     
    4756}}}
    4857
    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.
    5058
    51 
    52 == XML.vim ==
    53 
     59=== XML.vim ===
    5460The [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.
    5561
    56 == Syntax for templates ==
     62=== Syntax for templates ===
    5763
    5864Dave Hodder has contributed standard [http://www.vim.org/scripts/script.php?script_id=1487 Vim syntax files].
     
    7379}}}
    7480
    75 == Project.vim ==
    7681
     82=== Project.vim ===
    7783The [http://www.vim.org/scripts/script.php?script_id=69 Project] plugin adds IDE file organisation functionality to Vim.
    7884
     
    111117Such a structure can also be created by using the build in '\C' command which will recurse through the whole directory tree.
    112118
    113 == PIDA ==
     119== Vim/IDE ==
     120=== PIDA ===
    114121
    115122Although 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 :).
Back to Top