GitHub - tommcdo/vim-lion: A simple alignment operator for Vim text editor
source link: https://github.com/tommcdo/vim-lion
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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 targeted 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);
$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',
);
$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 pressing
Enter
).
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.git
Once 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_spaces g: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);
Recommend
-
49
README.md ninja-feet.vim In Practical Vim by Drew Neil, a...
-
5
Mountain Lion misery with AirPlay Last summer, I wrote about the lack of coverage for Airplay on Apple's actual computer line. In short, you could throw basically any...
-
8
Alternative explanations for mountain lion safety signs Writing Software, technology, sysadmin war stories, and more. Saturday, March 10, 2012 Alternati...
-
7
OS X Lion is one broken big cat Stay far away from OS X Lion if you value your sanity. If your iCal broke when you upgraded your mobile device(s) to iOS 5 and iCloud, this will not fix it the way you want. Oh, it might sta...
-
3
VMware 9 安装 Mac OS X 10.8 Mountain Lion 图文全程 2012-10-20 — Yanbin 本教程是在 VMware 9 下安装当前最新版的 Mac OS X Mountain Lion 苹果系统。曾在 VirtualBox/VMware 下安装过 Mac OS Lion 系统,但安装后是无法升级到 Mountain L...
-
9
Flight of the Sky Lion: 'Like VR but without the headset'Flight of the Sky Lion: 'Like VR but without the headset'Flight of the Sky Lion at the Legoland Windsor Re...
-
8
exchange.vim Easy text exchange operator for Vim. Mappings cx On the first use, define the first {motion} to exchange. On the second use, define the second {motion} and perform the exchange.
-
5
Apple finally makes OS X Lion and Mountain Lion free to downloadNews
-
4
MISSIVES. (see all)THIS WEEKEND: I’m playing TBH in a charity stream!July 9th, 2021
-
3
How to compile GDB in Mountain Lion (updated) This is an up-to-date version of the old original post about recompilin...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK