Change option name and shorthand notations

- `mode_sequence` (`ms`) -> `align` (`a`)
- `stick_to_left` (`<` / `s01`)

This commit does not break backward compatibility.
`mode_sequence` is still allowed.
This commit is contained in:
Junegunn Choi
2014-07-23 22:15:01 +09:00
parent f9a49e441d
commit 2fa6a040f6
5 changed files with 179 additions and 87 deletions

View File

@@ -1,4 +1,4 @@
easy-align.txt vim-easy-align Last change: May 31 2014
easy-align.txt vim-easy-align Last change: July 23 2014
VIM-EASY-ALIGN - TABLE OF CONTENTS *easyalign* *easy-align* *easy-align-toc*
==============================================================================
@@ -158,7 +158,7 @@ shortcuts for the most common use cases with the concept of "alignment rule".
An alignment rule is a predefined set of options for common alignment tasks,
which is identified by a single character, DELIMITER KEY, such as <Space> ,
`=`, `:`, `.`, `|`, `&`, and `,`.
`=`, `:`, `.`, `|`, `&`, `#`, and `,`.
Think of it as a shortcut. Instead of writing regular expression and setting
several options, you can just type in a single character.
@@ -231,7 +231,7 @@ With these mappings, you can align text with only a few keystrokes.
- `-` Around the last occurrences of delimiters (`-1`)
- `-2` Around the second to last occurrences of delimiters
- ...
4. Delimiter key (a single keystroke; <Space> , `=`, `:`, `.`, `|`, `&`, `,`)
4. Delimiter key (a single keystroke; <Space> , `=`, `:`, `.`, `|`, `&`, `#`, `,`)
Predefined alignment rules~
@@ -246,6 +246,7 @@ Predefined alignment rules~
`.` | Multi-line method chaining
`,` | Multi-line method arguments
`&` | LaTeX tables (matches `&` and `\\` )
`#` | Ruby/Python comments
<Bar> | Table markdown
*g:easy_align_delimiters*
@@ -260,13 +261,13 @@ Examples~
*easy-align-5-3-2*
With visual map | Description | Equivalent command~
------------------- | ---------------------------------- | ----------------------
------------------- | ---------------------------------- | ---------------------
<Enter><Space> | Around 1st whitespaces | :'<,'>EasyAlign\
<Enter>2<Space> | Around 2nd whitespaces | :'<,'>EasyAlign2\
<Enter>-<Space> | Around the last whitespaces | :'<,'>EasyAlign-\
<Enter>-2<Space> | Around the 2nd to last whitespaces | :'<,'>EasyAlign-2\
<Enter>: | Around 1st colon (`key: value`) | :'<,'>EasyAlign:
<Enter><Right>: | Around 1st colon (`key : value`) | :'<,'>EasyAlign:s0l1
<Enter><Right>: | Around 1st colon (`key : value`) | :'<,'>EasyAlign:<l1
<Enter>= | Around 1st operators with = | :'<,'>EasyAlign=
<Enter>3= | Around 3rd operators with = | :'<,'>EasyAlign3=
<Enter>*= | Around all operators with = | :'<,'>EasyAlign*=
@@ -306,7 +307,7 @@ following sections (|easy-align-alignment-options|).
CTRL-D | `delimiter_align` | left, center, right
CTRL-U | `ignore_unmatched` | 0, 1
CTRL-G | `ignore_groups` | [], ['String'], ['Comment'], ['String', 'Comment']
CTRL-O | `mode_sequence` | Input string (`/[lrc]+\*{0,2}/` )
CTRL-A | `align` | Input string (`/[lrc]+\*{0,2}/` )
<Left> | `stick_to_left` | `{ 'stick_to_left': 1, 'left_margin': 0 }`
<Right> | `stick_to_left` | `{ 'stick_to_left': 0, 'left_margin': 1 }`
<Down> | `*_margin` | `{ 'left_margin': 0, 'right_margin': 0 }`
@@ -375,20 +376,20 @@ You can even omit spaces between the arguments, so concisely (or cryptically):
Nice. But let's make it even shorter. Option values can be written in shorthand
notation.
- `:EasyAlign*/[:;]\+/s1l0`
- `:EasyAlign*/[:;]\+/<l0`
The following table summarizes the shorthand notation.
Option | Expression~
------------------ | ----------
------------------ | --------------
`filter` | `[gv]/.*/`
`left_margin` | `l[0-9]+`
`right_margin` | `r[0-9]+`
`stick_to_left` | `s[01]`
`stick_to_left` | `<` or `s[01]`
`ignore_unmatched` | `iu[01]`
`ignore_groups` | `ig\[.*\]`
`align` | `a[lrc*]*`
`delimiter_align` | `d[lrc]`
`mode_sequence` | `m[lrc*]*`
`indentation` | `i[ksdn]`
For your information, the same operation can be done in interactive mode as
@@ -448,7 +449,7 @@ ALIGNMENT OPTIONS *easy-align-alignment-options*
`ignore_unmatched` | boolean | 1 | Whether to ignore lines without matching delimiter
`indentation` | string | `k` | Indentation method (keep, deep, shallow, none)
`delimiter_align` | string | `r` | Determines how to align delimiters of different lengths
`mode_sequence` | string | | Alignment modes for multiple occurrences of delimiters
`align` | string | | Alignment modes for multiple occurrences of delimiters
There are 4 ways to set alignment options (from lowest precedence to highest):
@@ -470,7 +471,7 @@ There are 4 ways to set alignment options (from lowest precedence to highest):
`ignore_unmatched` | CTRL-U | `iu[01]` | `g:easy_align_ignore_unmatched`
`indentation` | CTRL-I | `i[ksdn]` | `g:easy_align_indentation`
`delimiter_align` | CTRL-D | `d[lrc]` | `g:easy_align_delimiter_align`
`mode_sequence` | CTRL-O | `m[lrc*]*` |
`align` | CTRL-A | `m[lrc*]*` |
< Filtering lines >___________________________________________________________~
@@ -556,7 +557,10 @@ For example if you set `ignore_groups` option to be an empty list, you get
'grape: fruits': 3
}
<
Satisfied?
If a pattern in `ignore_groups` is prepended by a `!`, it will have the
opposite meaning. For instance, if `ignore_groups` is given as `['!Comment']`,
delimiters that are not highlighted as Comment will be ignored during the
alignment.
< Ignoring unmatched lines >__________________________________________________~
@@ -724,36 +728,36 @@ To recap:
:EasyAlign! **=
<
In addition to these, you can fine-tune alignments over multiple occurrences of
the delimiters with 'mode_sequence' option. (The option can also be set in
interactive mode with the special key CTRL-O)
the delimiters with 'align' option. (The option can also be set in interactive
mode with the special key CTRL-A)
>
" Left alignment over the first two occurrences of delimiters
:EasyAlign = { 'mode_sequence': 'll' }
:EasyAlign = { 'align': 'll' }
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
:EasyAlign = { 'm': 'rlc' }
:EasyAlign = { 'a': 'rlc' }
" Using shorthand notation
:EasyAlign = mrlc
:EasyAlign = arlc
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
:EasyAlign 2=mrlc
:EasyAlign 2=arlc
" (*) Repeating alignments (default: l, r, or c)
" Right, left, center, center, center, center, ...
:EasyAlign *=mrlc
:EasyAlign *=arlc
" (**) Alternating alignments (default: lr or rl)
" Right, left, center, right, left, center, ...
:EasyAlign **=mrlc
:EasyAlign **=arlc
" Right, left, center, center, center, ... repeating alignment
" over the 3rd to the last occurrences of delimiters
:EasyAlign 3=mrlc*
:EasyAlign 3=arlc*
" Right, left, center, right, left, center, ... alternating alignment
" over the 3rd to the last occurrences of delimiters
:EasyAlign 3=mrlc**
:EasyAlign 3=arlc**
<
< Extending alignment rules >_________________________________________________~
@@ -774,8 +778,10 @@ Examples~
>
let g:easy_align_delimiters = {
\ '>': { 'pattern': '>>\|=>\|>' },
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignore_groups': ['String'] },
\ '#': { 'pattern': '#\+', 'ignore_groups': ['String'], 'delimiter_align': 'l' },
\ '/': {
\ 'pattern': '//\+\|/\*\|\*/',
\ 'delimiter_align': 'l',
\ 'ignore_groups': ['!Comment'] },
\ ']': {
\ 'pattern': '[[\]]',
\ 'left_margin': 0,
@@ -789,8 +795,8 @@ Examples~
\ 'stick_to_left': 0
\ },
\ 'd': {
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
\ 'left_margin': 0,
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
\ 'left_margin': 0,
\ 'right_margin': 0
\ }
\ }