Ⅰ. 插件描述
Automatically create JSDoc comments for functions using UltiSnips for VimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'jordwalke/vimjsdocsnippets'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'jordwalke/vimjsdocsnippets'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'jordwalke/vimjsdocsnippets'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/jordwalke/vimjsdocsnippets
Ⅳ. 文档说明
VimJSDocSnippets
Automatically create JSDoc comments for functions using UltiSnips
Installation
- Ensure that
UltiSnipsis installed, then installJSDocSnippets(this plugin) usingVundleorNeoBundle.
" Using Vundle
Bundle 'SirVer/ultisnips'
Bundle 'jordwalke/JSDocSnippets'
" Or if using NeoBundle(recommended)
NeoBundle 'SirVer/ultisnips'
NeoBundle 'jordwalke/JSDocSnippets'
- Define your desired keyboard mapping in a
.vimrcfile:let g:JSDocSnippetsMapping='<D-C>'
Usage
Assuming the keyboard mapping above, place your cursor on the line immediately
above any function, and press the keyboard mapping Command + shift + c.
var myFunc = function(one, two) {
// ...
}
Snippets will expand for all of the parameters, and you'll be able to tab
through all of them as you would with any other snippet.
/**
* @param {varType} one Description
* @param {varType} two Description
* @return {void} description
*/
var myFunc = function(one, two) {
// ...
}
JSDocSnippets also works with ES6 fat arrow functions.
var myFatArrowFunc = (one, two) => {
// ...
}
/**
* @param {varType} one Description
* @param {varType} two Description
* @return {void} description
*/
var myFatArrowFunc = (one, two) => {
// ...
}
Support
Only tested on MacVim, but probably works in other environments. The JSDoc formatting is not customizable yet - pull requests encouraged. This script was simply thrown together to scratch an itch.
These two examples were used as a starting point:
http://stackoverflow.com/questions/7942738/vim-plugin-to-generate-javascript-documentation-comments
https://github.com/distracteddev/jsDocBlock/commit/7994b9c576a010bd2cacd24358454a8879586594