Ⅰ. 插件描述
switch text with predefined replacementsⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'syngan/vim-clurin'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'syngan/vim-clurin'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'syngan/vim-clurin'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/syngan/vim-clurin
Ⅳ. 文档说明
vim-clurin
usage
nmap + <Plug>(clurin-next)
nmap - <Plug>(clurin-prev)
vmap + <Plug>(clurin-next)
vmap - <Plug>(clurin-prev)customize
g:clurin: Dictionary of Dictionary. key: - or 'filetype'
def (List of GROUP, required)
use_default (Bool, 1)
use_default_user (Bool, 1)
nomatch (Funcref({cnt}), none)
jump (Bool, 0) 0: under the cursor, otherwise: after the cursor
GROUP:: Dictionary or group
cyclic (Bool, 1)
group (List of Dictionary or Strings)
Dictionary:
pattern (String)
replace (String or Funcref({str},{cnt},{def}))
{str}: matched text
{cnt}: count
{def}: normalized def.
String {s}
string. NOTE: cannot use regexp .
-> {'pattern': '\<\({s}\)\>', 'replace' '{s}'} ({s}='^\k\+$') or
{'pattern': '\({s}\)', 'replace' '{s}'}example
function! g:CountUp(str, cnt, def) abort
" a:str: matched_text
" a:cnt: non zero.
" a:def: definition
return str2nr(a:str) + a:cnt
endfunction
function! g:CtrlAX(cnt) abort
if a:cnt >= 0
execute 'normal!' a:cnt . "\<C-A>"
else
execute 'normal!' (-a:cnt) . "\<C-X>"
endif
endfunction
let g:clurin = {
\ '-': { 'def': [[
\ {'pattern': '\(-\?\d\+\)', 'replace': function('g:CountUp')},
\ ], [
\ {'pattern': '\<true\>', 'replace': 'true'},
\ {'pattern': '\<false\>', 'replace': 'false'},
\ ], [
\ 'on', 'off'
\ ]]},
\ 'vim': {'def': [[
\ {'pattern': '''\(\k\+\)''', 'replace': '''\1'''},
\ {'pattern': '"\(\k\+\)"', 'replace': '"\1"'},
\ ]]},
\ 'c' : {'def': [
\ [ '&&', '||' ],
\ [
\ {'pattern': '\(\k\+\)\.', 'replace': '\1.'},
\ {'pattern': '\(\k\+\)->', 'replace': '\1->'},
\ ]], 'nomatch': function('g:CtrlAX')},
\}recipe
ruby string: 'string' -> "string" -> :string
\ [
\ {'pattern': '''\(\k\+\)''', 'replace': '''\1'''},
\ {'pattern': '"\(\k\+\)"', 'replace': '"\1"'},
\ {'pattern': ':\(\k\+\)"', 'replace': ':\1'},
\ ]closure string: 'string -> "string" -> :string
\ [
\ {'pattern': '''\(\k\+\)', 'replace': '''\1'},
\ {'pattern': '"\(\k\+\)"', 'replace': '"\1"'},
\ {'pattern': ':\(\k\+\)"', 'replace': ':\1'},
\ ]vim dictionary: ['key'] -> ["key"] -> .key
\ [
\ {'pattern': '\[''\(\k\+\)''\]', 'replace': '[''\1'']'},
\ {'pattern': '\["\(\k\+\)"\]', 'replace': '["\1"]'},
\ {'pattern': '\.\(\k\+\)', 'replace': '.\1'},
\ ]