mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-12 11:53:49 -05:00
Update documentation
This commit is contained in:
@@ -107,7 +107,29 @@ repeatable, non-interactive command recorded in `g:easy_align_last_command`.
|
||||
:<C-R>=g:easy_align_last_command<Enter><Enter>
|
||||
|
||||
|
||||
Non-interactive mode (command line)
|
||||
Left/right/center mode switch in interactive mode
|
||||
-------------------------------------------------------------------------
|
||||
*g:easy_align_interactive_modes*
|
||||
*g:easy_align_bang_interactive_modes*
|
||||
|
||||
In interactive mode, you can choose the alignment mode you want by pressing
|
||||
enter keys. The non-bang command, `:EasyAlign` starts in left-alignment mode
|
||||
and changes to right and center mode as you press enter keys, while the bang
|
||||
version first starts in right-alignment mode.
|
||||
|
||||
- `:EasyAlign`
|
||||
- Left, Right, Center
|
||||
- `:EasyAlign!`
|
||||
- Right, Left, Center
|
||||
|
||||
If you do not prefer this default mode transition, you can define your own
|
||||
settings as follows.
|
||||
|
||||
let g:easy_align_interactive_modes = ['l', 'r']
|
||||
let g:easy_align_bang_interactive_modes = ['c', 'r']
|
||||
|
||||
|
||||
Using EasyAlign in command line
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
Instead of going into the interactive mode, you can type in arguments to
|
||||
@@ -150,8 +172,8 @@ You can even omit spaces between the arguments, so concisely (or cryptically):
|
||||
|
||||
:EasyAlign*/[:;]\+/{'s':1,'l':''}
|
||||
|
||||
Nice. But let's make it even shorter. When you use write regular expression in
|
||||
command line, option values can be written in shorthand notation.
|
||||
Nice. But let's make it even shorter. Option values can be written in shorthand
|
||||
notation.
|
||||
|
||||
:EasyAlign*/[:;]\+/s1l0
|
||||
|
||||
@@ -265,7 +287,7 @@ You can change the default rule by using one of these 4 methods.
|
||||
2. Define global `g:easy_align_ignore_groups` list
|
||||
3. Define a custom rule in `g:easy_align_delimiters` with 'ignore_groups' option
|
||||
4. Provide 'ignore_groups' option to `:EasyAlign` command.
|
||||
e.g. :EasyAlign:{'is':[]}
|
||||
e.g. :EasyAlign:ig[]
|
||||
|
||||
For example if you set 'ignore_groups' option to be an empty list, you get
|
||||
|
||||
@@ -282,10 +304,18 @@ For example if you set 'ignore_groups' option to be an empty list, you get
|
||||
Ignoring unmatched lines *g:easy_align_ignore_unmatched*
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
Lines without any matching delimiter are ignored as well (except in
|
||||
right-align mode).
|
||||
'ignore_unmatched' option determines how EasyAlign command processes lines that
|
||||
do not have N-th delimiter.
|
||||
|
||||
For example, when aligning the following code block around the colons,
|
||||
1. In left-alignment mode, they are ignored
|
||||
2. In right or center-alignment mode, they are not ignored, and the last
|
||||
tokens from those lines are aligned as well as if there is an invisible
|
||||
trailing delimiter at the end of each line
|
||||
3. If 'ignore_unmatched' is 1, they are ignored regardless of the alignment mode
|
||||
4. If 'ignore_unmatched' is 0, they are not ignored regardless of the mode
|
||||
|
||||
Let's take an example.
|
||||
When we align the following code block around the (1st) colons,
|
||||
|
||||
{
|
||||
apple: proc {
|
||||
@@ -305,14 +335,14 @@ this is usually what we want.
|
||||
grapefruits: 3
|
||||
}
|
||||
|
||||
However, this default behavior is also configurable by using one of these 4
|
||||
methods.
|
||||
However, we can override this default behavior by setting 'ignore_unmatched'
|
||||
option to zero using one of the following methods.
|
||||
|
||||
1. Press CTRL-U in interactive mode to toggle 'ignore_unmatched' option
|
||||
2. Set the global `g:easy_align_ignore_unmatched` variable to 0
|
||||
3. Define a custom alignment rule with 'ignore_unmatched' option set to 0
|
||||
4. Provide 'ignore_unmatched' option to `:EasyAlign` command.
|
||||
e.g. :EasyAlign:{'iu':0}
|
||||
e.g. :EasyAlign:iu0
|
||||
|
||||
Then we get,
|
||||
|
||||
@@ -342,13 +372,13 @@ By default, delimiters are right-aligned as follows.
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
|
||||
However, with ':EasyAlign={'da':l}', delimiters are left-aligned.
|
||||
However, with ':EasyAlign=dl', delimiters are left-aligned.
|
||||
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
|
||||
And on ':EasyAlign={'da':c}', center-aligned.
|
||||
And on ':EasyAlign=dc', center-aligned.
|
||||
|
||||
apple = 1
|
||||
banana += apple
|
||||
@@ -379,7 +409,7 @@ But then again we have 'indentation' option. See the following example.
|
||||
eggplant = 5
|
||||
|
||||
# Use the _s_hallowest indentation among the lines
|
||||
# :EasyAlign={'idt':s}
|
||||
# :EasyAlign=is
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
@@ -387,7 +417,7 @@ But then again we have 'indentation' option. See the following example.
|
||||
eggplant = 5
|
||||
|
||||
# Use the _d_eepest indentation among the lines
|
||||
# :EasyAlign={'idt':d}
|
||||
# :EasyAlign=id
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
@@ -395,7 +425,7 @@ But then again we have 'indentation' option. See the following example.
|
||||
eggplant = 5
|
||||
|
||||
# Indentation: _n_one
|
||||
# :EasyAlign={'idt':n}
|
||||
# :EasyAlign=in
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
@@ -408,28 +438,6 @@ Notice that 'idt' is fuzzy-matched to 'indentation'.
|
||||
In interactive mode, you can change the option value with `CTRL-I` key.
|
||||
|
||||
|
||||
Left/right/center mode switch in interactive mode
|
||||
-------------------------------------------------------------------------
|
||||
*g:easy_align_interactive_modes*
|
||||
*g:easy_align_bang_interactive_modes*
|
||||
|
||||
In interactive mode, you can choose the alignment mode you want by pressing
|
||||
enter keys. The non-bang command, `:EasyAlign` starts in left-alignment mode
|
||||
and changes to right and center mode as you press enter keys, while the bang
|
||||
version first starts in right-alignment mode.
|
||||
|
||||
- `:EasyAlign`
|
||||
- Left, Right, Center
|
||||
- `:EasyAlign!`
|
||||
- Right, Left, Center
|
||||
|
||||
If you do not prefer this default mode transition, you can define your own
|
||||
settings as follows.
|
||||
|
||||
let g:easy_align_interactive_modes = ['l', 'r']
|
||||
let g:easy_align_bang_interactive_modes = ['c', 'r']
|
||||
|
||||
|
||||
Alignments over multiple occurrences of delimiters
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
@@ -466,24 +474,27 @@ in interactive mode with the special key CTRL-O)
|
||||
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
|
||||
:EasyAlign = { 'm': 'rlc' }
|
||||
|
||||
" Using shorthand notation
|
||||
:EasyAlign = mrlc
|
||||
|
||||
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
|
||||
:EasyAlign 2={ 'm': 'rlc' }
|
||||
:EasyAlign 2=mrlc
|
||||
|
||||
" (*) Repeating alignments (default: l, r, or c)
|
||||
" Right, left, center, center, center, center, ...
|
||||
:EasyAlign *={ 'm': 'rlc' }
|
||||
:EasyAlign *=mrlc
|
||||
|
||||
" (**) Alternating alignments (default: lr or rl)
|
||||
" Right, left, center, right, left, center, ...
|
||||
:EasyAlign **={ 'm': 'rlc' }
|
||||
:EasyAlign **=mrlc
|
||||
|
||||
" Right, left, center, center, center, ... repeating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3={ 'm': 'rlc*' }
|
||||
:EasyAlign 3=mrlc*
|
||||
|
||||
" Right, left, center, right, left, center, ... alternating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3={ 'm': 'rlc**' }
|
||||
:EasyAlign 3=mrlc**
|
||||
|
||||
|
||||
Extending alignment rules *g:easy_align_delimiters*
|
||||
|
||||
Reference in New Issue
Block a user