Ⅰ. 插件描述
A simple alignment operator for Vim text editorⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'tommcdo/vim-lion'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'tommcdo/vim-lion'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'tommcdo/vim-lion'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/tommcdo/vim-lion
Ⅳ. 文档说明
lion.vim
Lion.vim is a tool for aligning text by some character. It defines some
Vim operators that can be used with motion commands to align a targetted
block of text.
The two operators are gl and gL. gl will add spaces to the left of
the alignment character, and gL will add spaces to the right. Both
operators accept a count, a motion, and a single character. Without a
count, all occurrences of the character will be aligned.
For example, glip= will turn
$i = 5;
$username = 'tommcdo';
$stuff = array(1, 2, 3);into
$i = 5;
$username = 'tommcdo';
$stuff = array(1, 2, 3);Typing 3gLi(, with the cursor somewhere inside ( and ) will turn
$names = array(
'bill', 'samantha', 'ray', 'ronald',
'mo', 'harry', 'susan', 'ted',
'timothy', 'bob', 'wolverine', 'cat',
'lion', 'alfred', 'batman', 'linus',
);into
$names = array(
'bill', 'samantha', 'ray', 'ronald',
'mo', 'harry', 'susan', 'ted',
'timothy', 'bob', 'wolverine', 'cat',
'lion', 'alfred', 'batman', 'linus',
);It is also possible to align text by a pattern. To enter a pattern, use / as
the alignment character (e.g. glip/) and then you will be prompted to input
the pattern. To align by /, simply leave the pattern empty (by pressingEnter).
Installation
If you don't have a preferred installation method, I recommend
installing pathogen.vim, and
then simply copy and paste:
cd ~/.vim/bundle
git clone git://github.com/tommcdo/vim-lion.gitOnce help tags have been generated, you can view the manual with:help lion.
Options
| Option | Description | Default |
|---|---|---|
g:lion_create_maps | Whether to create mappings | 1 |
b:lion_squeeze_spacesg:lion_squeeze_spaces | Squeeze extra spaces | 0 |
g:lion_map_right | Mapping for right-align operator | gl |
g:lion_map_left | Mapping for left-align operator | gL |
If you set: let b:lion_squeeze_spaces = 1, and hit glip=, you will turn
$i = 5;
$user = 'tommcdo';
$stuff = array(1, 2, 3);into:
$i = 5;
$user = 'tommcdo';
$stuff = array(1, 2, 3);instead of (b:lion_squeeze_spaces = 0):
$i = 5;
$user = 'tommcdo';
$stuff = array(1, 2, 3);