Ⅰ. 插件描述
:guitar: Improvements to the handling of Django related files in VimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'tweekmonster/django-plus-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'tweekmonster/django-plus-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'tweekmonster/django-plus-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/tweekmonster/django-plus.vim
Ⅳ. 文档说明
<p align="center">
</p>
Improvements to the handling of Django related files in Vim, some of which are
based on Steve Losh's htmldjango scripts.
Why?
Django support in Vim sucks.
| What Sucks? | Sucks? |
|---|---|
Hard-coded htmldjango filetype for any .html file | Yes |
| HTML indentation | Yes |
QuerySet completions | Yes |
settings.py variable completions | Yes |
| Template tag and filter completions | Yes |
Template file completion for {% include %} and {% extends %} | Yes |
| Template file completion for rendering functions | Yes |
To help you understand the difference this plugin makes, I used science:

As you can see, one line goes up. However, the other line doesn't go up that
- It doesn't get any clearer than that.
Improvements
A summary of improvements to Django development in Vim.
General
- Django is detected by searching parent directories for clues that indicate
the current file is within a Django project. b:is_djangois set in any file that's within a Django project. This could
be useful for your personal scripts.b:is_django_settingsis set if the file issettings.pyor if the file is
in the same directory assettings.py. (b:is_djangowill still be set)- Optionally append
.djangoto thefiletypefor files found within a Django
project. - If a Django project's
manage.pyscript is found, completions will include
your settings and templatetags found inINSTALLED_APPS. g:django_filetypestakes a list of glob patterns to append thedjango
filetype to matching files. e.g.*.xmlwill have the filetype
xml.django if the file is found in a Django project.
Python
- Completions for Django settings when
b:is_django_settingsis present. - Completions for
settings.whenb:is_djangois present in a.pyfile. - Completions for template files when using
render(),get_template(),render_to_string(),render_to_response(), ortemplate_name =. - QuerySets could be lurking anywhere. That's why QuerySet completions will be
included for basically anything after a period. - If you are using
Ultisnips, Django snippets are enabled andUltiSnips#FileTypeChanged()is called to ensure that:UltiSnipsEditopens
django.snippets by default instead of python.snippets.
HTML
- The filetype is set to
htmldjangowhen editing HTML files. - Basic completions for template tags and filters.
- Completions for template files when using
{% extends %}or{% include %}. - Django tags are indented correctly, including custom tags.
matchitconfiguration for Django tags, including custom tags.
Additionally, the cursor is placed at the beginning of the tag name.- Tag and variable blocks are highlighted within script tags, style tags, and
HTML attributes. - If you are using Ultisnips, HTML snippets are enabled and
UltiSnips#FileTypeChanged()is called to ensure that:UltiSnipsEditopens
htmldjango.snippets by default instead of html.snippets.