Ⅰ. 插件描述
Inserting snippets in new lineⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/smart-cr'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/smart-cr'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/smart-cr'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/smart_cr
Ⅳ. 文档说明
Deprecated, use vimscript#1957
Example
Perhaps you editing C file:
#include <stdlib.h*>
(* - cursor position)
If you hit Enter, new include directive will be inserted:
#include <stdlib.h>
#include <*>
Configuration
You must create new hash g:smart_cr
let g:smart_cr = {}
Hash must contain arrays for different filetypes:
let g:smart_cr.c = [['^#include <', '^>$', "#include <@@@>"],
['^#include "', '^"$', "#include "@@@""]]
When you hit Enter, line is divided on two parts - before and above
the cursor. First two strings are regular expressions for left and
right parts of line. If they matched, third string will be inserted in
new line.
"@@@" is marker where to place cursor. You may redefine it by setting
global variable:
let g:smart_cr_marker = '<here>'
Another example
This for Embedded ruby:
let g:smart_cr.eruby = [['<%1', '^s*%>', "<% @@@ %>"],
['<%1', '^s*-%>', "<% @@@ -%>"],
['<%=', '^s*%>', "<%= @@@ %>"],
['<%=', '^s*-%>', "<%= @@@ -%>"]]
- = ↩