Abolish.vim 简介
abolish
vim-abolish 是 vim 艺术家 Tim Pope 的作品,在处理英文单词大小写方面有很强大的作用。
It's three superficially unrelated plugins in one that share a common theme: working with variants of a word.
安装和配置
使用 vim-plug 只需添加:
Plug 'tpope/vim-abolish'
使用
abbrev 增强
abbrev 可以帮助纠正一些拼写错误,比如纠正 main 写成 mian 的错误:
abbrev mian main
Abolish.vim 增强了这一功能,使得写成 Mian 也可以纠正过来:
Abolish mian main
更强大的大括号功能,可以匹配更多:
:Abolish {despa,sepe}rat{e,es,ed,ing,ely,ion,ions,or} {despe,sepa}rat{}
neovim 用户可以在.config/nvim/after/plugin 路径下新建文件 abolish.vim,在其中填写自己的设置:
Abolish {despa,sepe}rat{e,es,ed,ing,ely,ion,ions,or} {despe,sepa}rat{}
Abolish mian main
after 中的代码会在所有插件加载完成后执行。
替换增强
上面的大括号匹配功能适用于替换功能:
%Subvert/facilit{y,ies}/building{,s}/g
这一命令可使 facility 替换为 building,使 facilities 替换为 buildings,非常简洁高效。
Coercion 强制转换
遇到下面这些需求时,coercion 将成为得力助手:
- camelCase 转换为 snake_case
- snake_case 转换为 MixedCase
- MixedCase 转换为 UPPER_CASE
这在修改变量名时会非常方便。
| 按键 | 作用 |
|---|---|
| crs | coerce to snake_case |
| crm | coerce to MixedCase |
| crc | coerce to camelCase |
| crc | coerce to UPPER_CASE |
| cr. | coerce to dot.case |
| cr- | coerce to dash-case |
| cr |
coerce to space case |
| crt | coerce to Title Case |
浙公网安备 33010602011771号