Ⅰ. 插件描述
Next generation JavaScript and React snippets for Vim https://babeljs.ioⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'alnjxn/babel-vim-snippets'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'alnjxn/babel-vim-snippets'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'alnjxn/babel-vim-snippets'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/alnjxn/babel-vim-snippets
Ⅳ. 文档说明
# babel-vim-snippets
Next generation JavaScript and React snippets for Vim https://babeljs.io
A direct port of the snippets available from babel-sublime-snippets
Currently written with support for UltiSnips only.
Installation
Install your favorite Vim plugin manager. (i.e. Vundle, pathogen, vim-plug, neobundle)
Modify the following depending on your plugin manager and add to your .vimrc file. If you do not alread have UltiSnips installed you will need it for compatibility.
Example using neobundle
" UltiSnips required for compatability
NeoBundle 'SirVer/ultisnips'
" babel-vim-snippets
NeoBundle 'alnjxn/babel-vim-snippets'
" Other snippets (optional)
NeoBundle 'honza/vim-snippets'Available Snippets
ES6
React
| Trigger | Content |
|---|---|
rcc→ | class component skeleton |
rccl→ | legacy component skeleton |
rec→ | component skeleton |
cdm→ | componentDidMount() {…} |
cdup→ | componentDidUpdate(prevProps, prevState) {…} |
cwm→ | componentWillMount() {…} |
cwr→ | componentWillReceiveProps(nextProps) {…} |
cwun→ | componentWillUnmount() {…} |
cwup→ | componentWillUpdate(nextProps, nextState) {…} |
fdn→ | React.findDOMNode(…) |
gdp→ | getDefaultProps() {…} |
gis→ | getInitialState() {…} |
ren→ | render() {…} |
sst→ | this.setState(…) |
scu→ | shouldComponentUpdate(nextProps, nextState) {…} |
props→ | this.props |
state→ | this.state |
ToDo:
- [ ] Add snipmate support