Ⅰ. 插件描述
Lightweight bag of Vim utilities for Backbone - snipmate snippets, templates and omnicompletionⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'mklabs/vim-backbone'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'mklabs/vim-backbone'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'mklabs/vim-backbone'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/mklabs/vim-backbone
Ⅳ. 文档说明
# vim backbone
Collection of Backbone VIM snippets and templates.
Installation
Install for pathogen
cd ~/.vim/bundle
git clone git://github.com/mklabs/vim-backbone.gitDocumentation
work in progess
What it does
vim helpfile generated from backbonejs.org (:h backbone)

Snipmates snippets. When filetype is set to javascript, typeview<tab>, model<tab> or router<tab>
In insert mode, in a file where filetype=javascript, typing view
followed by <tab> will expand to the following snippet:
var MyView = Backbone.View.extend({
el: '',
tagName: '',
events: {
},
initialize: function () {
},
render: function () {
}
});Hitting tab again will iterate through snippets placeholders. See `:h
snipMate and :h snipMate-placeholders` for more infos.
Backbone specific omnicompleter.
:h new-omni-completion.
This could also be called "intellisense", but that is a trademark.
Should auto-complete whenever the text in front of the cursor includes amodel (this.model triggers the match). Same for collection, router
and view.
It works by inspecting the Backbone.Model.prototype object when
completing against a match that triggers model completion. It's not as
accurate as it would be in your devtool but should be pretty close.
Use CTRL-X CTRL-U in Insert mode to start the completion, when the
cursor in in front of the following:
model.
router.
controller.
view.
The plugin also map the <C-Space> (Ctrl+space) to trigger the same
omnicompletion.
In insert mode, in a file where filetype=javascript, typing modelormodel. followed by either Ctrl+X Ctrl+U or Ctrl+Space will pop the
following menu:

What it should do
- vim templates on
BufNewFile. Should this be node-based with mustache
like templates, and intelligently parse current filepath / app
structure to know which template it should use (eg. opening a new file
with something like */models/* or a filename with model in it
should trigger the model template.
- Ease navigation of the Backbone directory structure. eg. easy jumping
between files, like model to test, view to template, template to
helper, etc.
- Enhanced syntax highlighting, should this be useful
- Scripts wrapper around the scripts in the script directory of the
Backbone app. A limited amount of completion should be supported - Possibly integration and wrappers to build tool
- should have special logic / behaviour if a
spec/ortest/
directory is detected. - Commands to generate things. a
:Bgenerate model Fooshould create a
foo controller and editsapp/model/foo.js, optionally would be nice
to have the matching test generated app/test/foo.js with basic
assertions.