19 Commits
2.1.0 ... 2.2.0

Author SHA1 Message Date
Junegunn Choi
62314afcaf Fix typo 2013-08-19 15:16:19 +09:00
Junegunn Choi
cef26cdef9 Update EXAMPLES 2013-08-19 14:59:35 +09:00
Junegunn Choi
659e2ff513 Update README 2013-08-19 10:57:21 +09:00
Junegunn Choi
481a88f601 Update README 2013-08-19 04:21:02 +09:00
Junegunn Choi
6fb4f57b5a Add test cases for center-alignment 2013-08-19 04:14:56 +09:00
Junegunn Choi
beb986ebc3 Update documentation 2013-08-19 04:06:36 +09:00
Junegunn Choi
5222db47cf Rename align_mode to mode_sequence 2013-08-19 02:37:46 +09:00
Junegunn Choi
74003c0297 Allow interactive mode with options 2013-08-19 02:25:38 +09:00
Junegunn Choi
999e1ff68e Implement center-align mode and align_modes option 2013-08-19 02:09:34 +09:00
Junegunn Choi
11a74c4176 Fix right-justification for lines with different indentation 2013-08-16 23:47:01 +09:00
Junegunn Choi
e7e7a80afb Update doc 2013-08-16 17:58:05 +09:00
Junegunn Choi
29e5cd1d19 Add the link to slower GIF 2013-08-16 15:03:57 +09:00
Junegunn Choi
5c6558bd1b Improve right-justification mode
With this commit you can right-align the last token with * or ** field number.
For example, the following lines
    a = 1
    bb = 22
    ccc = 333
are aligned as follows on `:EasyAlign**=`
    a   =   1
    bb  =  22
    ccc = 333
And even if we don't have the second =, we can do `:EasyAlign!2=` to get
    a =     1
    bb =   22
    ccc = 333
2013-08-16 13:58:28 +09:00
Junegunn Choi
b6625f6d2b Fix: Unmatched token incorrectly ignored in right-justification mode 2013-08-16 09:37:04 +09:00
Junegunn Choi
d4277a0298 Fix a typo 2013-08-16 03:12:36 +09:00
Junegunn Choi
d31e6ed257 Update README 2013-08-16 02:37:24 +09:00
Junegunn Choi
1e2af43a64 Ignore unmatched line on right-justification mode
Unmatched line is NOT ignored on right-justification mode. However this
commit makes such a line ignored when the end of the line is highlighted
as one of the ignored syntax groups (e.g. Comments or Strings)
2013-08-16 02:23:00 +09:00
Junegunn Choi
0fb997d5ab Add g:easy_align_indentation. Add n indentation option. 2013-08-16 01:38:50 +09:00
Junegunn Choi
90a5487974 Add indentation option 2013-08-16 00:15:57 +09:00
9 changed files with 1015 additions and 151 deletions

View File

@@ -41,6 +41,7 @@ Try these commands:
- `<Enter>-2<space>`
- `<Enter><Enter><space>`
- `<Enter><Enter>*<space>`
- `<Enter><Enter><Enter>*<space>`
### Example
@@ -61,6 +62,7 @@ Try these commands:
- `<Enter>**|`
- `<Enter><Enter>*|`
- `<Enter><Enter>**|`
- `<Enter><Enter><Enter>*|`
### Example
@@ -90,6 +92,7 @@ Try these commands:
- `<Enter>*=`
- `<Enter>**=`
- `<Enter><Enter>**=`
- `<Enter><Enter><Enter>*=`
### Example
@@ -237,7 +240,7 @@ So, let's define a custom mapping for `#`.
if !exists('g:easy_align_delimiters')
let g:easy_align_delimiters = {}
endif
let g:easy_align_delimiters['#'] = { 'pattern': '#', 'ignores': ['String'] } }
let g:easy_align_delimiters['#'] = { 'pattern': '#', 'ignores': ['String'] }
```
Notice that the rule overrides `ignores` attribute in order *not to ignore*
@@ -282,7 +285,7 @@ let g:easy_align_ignore_unmatched = 0
" 3. Update the alignment rule with ignore_unmatched option
let g:easy_align_delimiters['#'] = {
\ 'pattern': '#', 'ignores': ['String'], 'ignore_unmatched': 0 } }
\ 'pattern': '#', 'ignores': ['String'], 'ignore_unmatched': 0 }
```
Then we get,

173
README.md
View File

@@ -1,13 +1,15 @@
vim-easy-align
==============
A simple, easy-to-use Vim alignment plugin without too much ambition.
A simple, easy-to-use Vim alignment plugin.
Demo
----
![Screencast](https://raw.github.com/junegunn/vim-easy-align/gif/vim-easy-align.gif)
(Too fast? Slower GIF is [here](https://raw.github.com/junegunn/vim-easy-align/gif/vim-easy-align-slow.gif))
Features
--------
@@ -40,14 +42,14 @@ then execute `:BundleInstall` command.
Usage
-----
_vim-easy-align_ defines `:EasyAlign` command (and the right-justification
_vim-easy-align_ defines `:EasyAlign` command (and the right-align
variant `:EasyAlign!`) in the visual mode.
| Mode | Command |
| ------------------------- | --------------------------------------------- |
| Interactive mode | `:EasyAlign` |
| Using predefined rules | `:EasyAlign [FIELD#] DELIMITER_KEY [OPTIONS]` |
| Using regular expressions | `:EasyAlign [FIELD#] /REGEXP/ [OPTIONS]` |
| Mode | Command |
| ------------------------- | ------------------------------------------------ |
| Interactive mode | `:EasyAlign[!] [OPTIONS]` |
| Using predefined rules | `:EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS]` |
| Using regular expressions | `:EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS]` |
### Interactive mode
@@ -59,10 +61,12 @@ your `.vimrc`.
vnoremap <silent> <Enter> :EasyAlign<cr>
```
(Of course you can use any key combination as the trigger. e.g. `<Leader>a`)
With the mapping, you can align selected lines of text with only a few keystrokes.
1. `<Enter>` key to start interactive EasyAlign command
1. Optional Enter keys to toggle right-justification mode
1. Optional Enter keys to select alignment mode (left, right, or center)
1. Optional field number (default: 1)
- `1` Around the 1st occurrences of delimiters
- `2` Around the 2nd occurrences of delimiters
@@ -85,6 +89,9 @@ Alignment rules for the following delimiters have been defined to meet the most
| `,` | Multi-line method arguments |
| &#124; | Table markdown |
You can override these default rules or define your own rules with
`g:easy_align_delimiters`, which will be described in the later section.
#### Example command sequences
| With visual map | Description | Equivalent command |
@@ -98,7 +105,7 @@ Alignment rules for the following delimiters have been defined to meet the most
| `<Enter>3=` | Alignment around 3rd equals signs (and the likes) | `:'<,'>EasyAlign3=` |
| `<Enter>*=` | Alignment around all equals signs (and the likes) | `:'<,'>EasyAlign*=` |
| `<Enter>**=` | Left-right alternating alignment around all equals signs | `:'<,'>EasyAlign**=` |
| `<Enter><Enter>=` | Right-justified alignment around 1st equals signs | `:'<,'>EasyAlign!=` |
| `<Enter><Enter>=` | Right alignment around 1st equals signs | `:'<,'>EasyAlign!=` |
| `<Enter><Enter>**=` | Right-left alternating alignment around all equals signs | `:'<,'>EasyAlign!**=` |
| ... | ... | |
@@ -139,7 +146,7 @@ Then we get:
apple;: banana:: cake
data;; exchange:; format
Options keys are fuzzy-matched, so you can write as follows:
Option names are fuzzy-matched, so you can write as follows:
- `:EasyAlign * /[:;]\+/ { 'stl': 1, 'l': 0 }`
@@ -179,7 +186,7 @@ since the same can be easily done using the negative field number: `<Enter>-=`
Alignment options
-----------------
Options values can be 1) specified as global variables, 2) set on each alignment
Option values can be 1) specified as global variables, 2) set on each alignment
rule in `g:easy_align_delimiters`, 3) or given to every `:EasyAlign` command.
Command-line options have the highest precedence, and global variables have the
@@ -187,16 +194,18 @@ lowest precedence.
### List of options
| Option | Type | Default | Description |
| ------------------ | ----------------- | ----------------------- | ------------------------------------------------------- |
| `left_margin` | number | 0 | Number of spaces to attach before delimiter |
| `left_margin` | string | `''` | String to attach before delimiter |
| `right_margin` | number | 0 | Number of spaces to attach after delimiter |
| `right_margin` | string | `''` | String to attach after delimiter |
| `stick_to_left` | boolean | 0 | Whether to position delimiter on the left-side |
| `ignore_unmatched` | boolean | 1 | Whether to ignore lines without matching delimiter |
| `ignores` | array | `['String', 'Comment']` | Delimiters in these syntax highlight groups are ignored |
| `delimiter_align` | string | `r` | Determines how to align delimiters of different lengths |
| Option | Type | Default | Description |
| ------------------ | ----------------- | --------------------- | ------------------------------------------------------- |
| `left_margin` | number | 0 | Number of spaces to attach before delimiter |
| `left_margin` | string | `''` | String to attach before delimiter |
| `right_margin` | number | 0 | Number of spaces to attach after delimiter |
| `right_margin` | string | `''` | String to attach after delimiter |
| `stick_to_left` | boolean | 0 | Whether to position delimiter on the left-side |
| `ignore_unmatched` | boolean | 1 | Whether to ignore lines without matching delimiter |
| `ignores` | list | ['String', 'Comment'] | Delimiters in these syntax highlight groups are ignored |
| `indentation` | string | `k` | Indentation method (*k*eep, *d*eep, *s*hallow, *n*one) |
| `delimiter_align` | string | `r` | Determines how to align delimiters of different lengths |
| `mode_sequence` | string | | Alignment modes for multiple occurrences of delimiters |
Some of the options can be specified using corresponding global variables.
@@ -205,6 +214,7 @@ Some of the options can be specified using corresponding global variables.
| `ignore_unmatched` | `g:easy_align_ignore_unmatched` |
| `ignores` | `g:easy_align_ignores` |
| `delimiter_align` | `g:easy_align_delimiter_align` |
| `indentation` | `g:easy_align_indentation` |
### Ignoring delimiters in comments or strings
@@ -271,7 +281,7 @@ Satisfied? :satisfied:
### Ignoring unmatched lines
Lines without any matching delimiter are ignored as well (except in
right-justification mode).
right-align mode).
For example, when aligning the following code block around the colons,
@@ -352,6 +362,123 @@ banana += apple
cake ||= banana
```
### Adjusting indentation
By default :EasyAlign command keeps the original indentation of the lines. But
then again we have `indentation` option. See the following example.
```ruby
# Lines with different indentation
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Default: _k_eep the original indentation
# :EasyAlign=
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Use the _s_hallowest indentation among the lines
# :EasyAlign={'idt':s}
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Use the _d_eepest indentation among the lines
# :EasyAlign={'idt':d}
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Indentation: _n_one
# :EasyAlign={'idt':n}
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
```
Notice that `idt` is fuzzy-matched to `indentation`.
### Left/right/center mode switch in interactive mode
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.
```vim
let g:easy_align_interactive_modes = ['l', 'r']
let g:easy_align_bang_interactive_modes = ['c', 'r']
```
### Alignments over multiple occurrences of delimiters
As stated above, "field number" is used to target specific occurrences of
the delimiter when it appears multiple times in each line.
To recap:
```vim
" Left-alignment around the FIRST occurrences of delimiters
:EasyAlign =
" Left-alignment around the SECOND occurrences of delimiters
:EasyAlign 2=
" Left-alignment around the LAST occurrences of delimiters
:EasyAlign -=
" Left-alignment around ALL occurrences of delimiters
:EasyAlign *=
" Left-right ALTERNATING alignment around all occurrences of delimiters
:EasyAlign **=
" Right-left ALTERNATING alignment around all occurrences of delimiters
:EasyAlign! **=
```
In addition to these, you can fine-tune alignments over multiple occurrences of
the delimiters with 'mode_sequence' option.
```vim
" Left alignment over the first two occurrences of delimiters
:EasyAlign = { 'mode_sequence': 'll' }
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
:EasyAlign = { 'm': 'rlc' }
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
:EasyAlign 2={ 'm': 'rlc' }
" (*) Repeating alignments (default: l, r, or c)
" Right, left, center, center, center, center, ...
:EasyAlign *={ 'm': 'rlc' }
" (**) Alternating alignments (default: lr or rl)
" Right, left, center, right, left, center, ...
:EasyAlign **={ 'm': 'rlc' }
```
### Extending alignment rules
Although the default rules should cover the most of the use cases,
@@ -365,7 +492,7 @@ let g:easy_align_delimiters = {
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignores': ['String'] },
\ '#': { 'pattern': '#\+', 'ignores': ['String'], 'delimiter_align': 'l' },
\ ']': {
\ 'pattern': '[\[\]]',
\ 'pattern': '[[\]]',
\ 'left_margin': 0,
\ 'right_margin': 0,
\ 'stick_to_left': 0

View File

@@ -39,12 +39,13 @@ let s:easy_align_delimiters_default = {
\ '}': { 'pattern': '}', 'left_margin': ' ', 'right_margin': '', 'stick_to_left': 0 }
\ }
let s:just = ['', '[R]']
let s:mode_labels = { 'l': '', 'r': '[R]', 'c': '[C]' }
let s:known_options = {
\ 'margin_left': [0, 1], 'margin_right': [0, 1], 'stick_to_left': [0],
\ 'left_margin': [0, 1], 'right_margin': [0, 1],
\ 'ignores': [3], 'ignore_unmatched': [0], 'delimiter_align': [1]
\ 'margin_left': [0, 1], 'margin_right': [0, 1], 'stick_to_left': [0],
\ 'left_margin': [0, 1], 'right_margin': [0, 1], 'indentation': [1],
\ 'ignores': [3 ], 'ignore_unmatched': [0 ], 'delimiter_align': [1],
\ 'mode_sequence': [1 ]
\ }
if exists("*strwidth")
@@ -81,7 +82,7 @@ endfunction
function! s:echon(l, n, d)
echon "\r"
echon "\rEasyAlign". s:just[a:l] ." (" .a:n.a:d. ")"
echon "\rEasyAlign". s:mode_labels[a:l] ." (" .a:n.a:d. ")"
endfunction
function! s:exit(msg)
@@ -97,6 +98,10 @@ function! s:rtrim(str)
return substitute(a:str, '\s*$', '', '')
endfunction
function! s:trim(str)
return substitute(a:str, '^\s*\(\S*\)\s*$', '\1', '')
endfunction
function! s:fuzzy_lu(key)
if has_key(s:known_options, a:key)
return a:key
@@ -110,10 +115,22 @@ function! s:fuzzy_lu(key)
elseif len(matches) == 1
return matches[0]
else
" Avoid ambiguity introduced by deprecated margin_left and margin_right
if index(matches, 'mode_sequence') != -1
return 'mode_sequence'
endif
call s:exit("Ambiguous option key: ". a:key ." (" .join(matches, ', '). ")")
endif
endfunction
function! s:shift(modes, cycle)
let item = remove(a:modes, 0)
if a:cycle || empty(a:modes)
call add(a:modes, item)
endif
return item
endfunction
function! s:normalize_options(opts)
let ret = {}
for k in keys(a:opts)
@@ -139,8 +156,10 @@ function! s:validate_options(opts)
return a:opts
endfunction
function! s:split_line(line, fc, lc, pattern, stick_to_left, ignore_unmatched, ignores)
let left = a:lc ?
function! s:split_line(line, nth, modes, cycle, fc, lc, pattern, stick_to_left, ignore_unmatched, ignores)
let mode = ''
let string = a:lc ?
\ strpart(getline(a:line), a:fc - 1, a:lc - a:fc + 1) :
\ strpart(getline(a:line), a:fc - 1)
let idx = 0
@@ -156,12 +175,16 @@ function! s:split_line(line, fc, lc, pattern, stick_to_left, ignore_unmatched, i
let ignorable = 0
let token = ''
while 1
let matches = matchlist(left, pattern, idx)
let matches = matchlist(string, pattern, idx)
" No match
if empty(matches) | break | endif
" Match, but empty delimiter
if empty(matches[1])
let char = strpart(left, idx, 1)
let char = strpart(string, idx, 1)
if empty(char) | break | endif
let [match, part, delim] = [char, char, '']
" Match
else
let [match, part, delim] = matches[1 : 3]
endif
@@ -170,48 +193,77 @@ function! s:split_line(line, fc, lc, pattern, stick_to_left, ignore_unmatched, i
if ignorable
let token .= match
else
let [pmode, mode] = [mode, s:shift(a:modes, a:cycle)]
call add(tokens, token . match)
call add(delims, delim)
let token = ''
endif
let idx += len(match)
" If the string is non-empty and ends with the delimiter,
" append an empty token to the list
if idx == len(string)
call add(tokens, '')
call add(delims, '')
break
endif
endwhile
let leftover = token . strpart(left, idx)
let leftover = token . strpart(string, idx)
if !empty(leftover)
let ignorable = s:highlighted_as(a:line, len(string) + a:fc - 1, a:ignores)
call add(tokens, leftover)
call add(delims, '')
endif
let [pmode, mode] = [mode, s:shift(a:modes, a:cycle)]
" Preserve indentation - merge first two tokens
if len(tokens) > 1 && empty(s:rtrim(tokens[0]))
let tokens[1] = tokens[0] . tokens[1]
call remove(tokens, 0)
call remove(delims, 0)
let mode = pmode
endif
" Skip comment line
if ignorable && len(tokens) == 1 && a:ignore_unmatched
let tokens = []
let delims = []
" Append an empty item to enable right/center alignment of the last token
" - if the last token is not ignorable or ignorable but not the only token
elseif (mode == 'r' || mode == 'c') && (!ignorable || len(tokens) > 1) && a:nth >= 0 " includes -0
call add(tokens, '')
call add(delims, '')
endif
return [tokens, delims]
endfunction
function! s:do_align(just, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth, ml, mr, da, stick_to_left, ignore_unmatched, ignores, recursive)
let lines = {}
let max_just_len = 0
let max_delim_len = 0
let max_tokens = 0
let min_indent = -1
function! s:max(old, new)
for k in keys(a:new)
if a:new[k] > a:old[k]
let a:old[k] = a:new[k] " max() doesn't work with Floats
endif
endfor
endfunction
function! s:do_align(modes, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth,
\ ml, mr, da, indentation, stick_to_left, ignore_unmatched, ignores, recur)
let mode = a:modes[0]
let lines = {}
let min_indent = -1
let max = { 'pivot_len': 0.0, 'token_len': 0, 'just_len': 0, 'delim_len': 0,
\ 'indent': 0, 'tokens': 0 }
" Phase 1
for line in range(a:fl, a:ll)
if !has_key(a:all_tokens, line)
" Split line into the tokens by the delimiters
let [tokens, delims] = s:split_line(line, a:fc, a:lc, a:pattern, a:stick_to_left, a:ignore_unmatched, a:ignores)
let [tokens, delims] = s:split_line(
\ line, a:nth, copy(a:modes), a:recur == 2,
\ a:fc, a:lc, a:pattern,
\ a:stick_to_left, a:ignore_unmatched, a:ignores)
" Remember tokens for subsequent recursive calls
let a:all_tokens[line] = tokens
@@ -227,15 +279,19 @@ function! s:do_align(just, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth,
endif
" Calculate the maximum number of tokens for a line within the range
let max_tokens = max([len(tokens), max_tokens])
call s:max(max, { 'tokens': len(tokens) })
if a:nth > 0 " Positive field number
if len(tokens) < a:nth
continue
endif
let nth = a:nth - 1 " make it 0-based
else " Negative field number
let nth = len(tokens) + a:nth
else " -0 or Negative field number
if a:nth == 0 && mode != 'l'
let nth = len(tokens) - 1
else
let nth = len(tokens) + a:nth
endif
if empty(delims[len(delims) - 1])
let nth -= 1
endif
@@ -249,7 +305,7 @@ function! s:do_align(just, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth,
let delim = delims[nth]
let token = s:rtrim( tokens[nth] )
let token = s:rtrim( strpart(token, 0, len(token) - len(s:rtrim(delim))) )
if empty(delim) && !exists('tokens[nth + 1]') && a:just == 0 && a:ignore_unmatched
if empty(delim) && !exists('tokens[nth + 1]') && a:ignore_unmatched
continue
endif
@@ -257,11 +313,42 @@ function! s:do_align(just, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth,
if min_indent < 0 || indent < min_indent
let min_indent = indent
endif
let max_just_len = max([s:strwidth(prefix.token), max_just_len])
let max_delim_len = max([s:strwidth(delim), max_delim_len])
let [pw, tw] = [s:strwidth(prefix), s:strwidth(token)]
call s:max(max, { 'indent': indent, 'token_len': tw, 'just_len': pw + tw,
\ 'delim_len': s:strwidth(delim), 'pivot_len': pw + tw / 2.0 })
let lines[line] = [nth, prefix, token, delim]
endfor
" Phase 1-5: indentation handling (only on a:nth == 1)
if a:nth == 1
if a:indentation ==? 'd'
let indent = repeat(' ', max.indent)
elseif a:indentation ==? 's'
let indent = repeat(' ', min_indent)
elseif a:indentation ==? 'n'
let indent = ''
elseif a:indentation !=? 'k'
call s:exit('Invalid indentation: ' . a:indentation)
end
if a:indentation !=? 'k'
let max.just_len = 0
let max.token_len = 0
let max.pivot_len = 0
for [line, elems] in items(lines)
let [nth, prefix, token, delim] = elems
let token = substitute(token, '^\s*', indent, '')
let [pw, tw] = [s:strwidth(prefix), s:strwidth(token)]
call s:max(max,
\ { 'token_len': tw, 'just_len': pw + tw, 'pivot_len': pw + tw / 2.0 })
let lines[line][2] = token
endfor
endif
endif
" Phase 2
for [line, elems] in items(lines)
let tokens = a:all_tokens[line]
@@ -274,21 +361,31 @@ function! s:do_align(just, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth,
endif
" Pad the token with spaces
let pad = repeat(' ', max_just_len - s:strwidth(prefix) - s:strwidth(token))
let [pw, tw] = [s:strwidth(prefix), s:strwidth(token)]
let rpad = ''
if a:just == 0
if mode == 'l'
let pad = repeat(' ', max.just_len - pw - tw)
if a:stick_to_left
let rpad = pad
else
let token = token . pad
endif
elseif a:just == 1
elseif mode == 'r'
let pad = repeat(' ', max.just_len - pw - tw)
let token = pad . token
elseif mode == 'c'
let p1 = max.pivot_len - (pw + tw / 2.0)
let p2 = (max.token_len - tw) / 2.0
let pf1 = floor(p1)
if pf1 < p1 | let p2 = ceil(p2)
else | let p2 = floor(p2)
endif
let token = repeat(' ', float2nr(pf1)) .token. repeat(' ', float2nr(p2))
endif
let tokens[nth] = token
" Pad the delimiter
let dpadl = max_delim_len - s:strwidth(delim)
let dpadl = max.delim_len - s:strwidth(delim)
if a:da ==? 'l'
let [dl, dr] = ['', repeat(' ', dpadl)]
elseif a:da ==? 'c'
@@ -314,8 +411,8 @@ function! s:do_align(just, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth,
" Adjust indentation of the lines starting with a delimiter
let lpad = ''
if nth == 0
let ipad = repeat(' ', min_indent - len(strpart(before.token, '^\s\+').ml))
if a:just == 0
let ipad = repeat(' ', min_indent - len(token.ml))
if mode == 'l'
let token = ipad . token
else
let lpad = ipad
@@ -331,32 +428,34 @@ function! s:do_align(just, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth,
call setline(line, newline)
endfor
if a:recursive && a:nth < max_tokens
let just = a:recursive == 2 ? !a:just : a:just
call s:do_align(just, a:all_tokens, a:all_delims, a:fl, a:ll, a:fc, a:lc, a:pattern,
\ a:nth + 1, a:ml, a:mr, a:da, a:stick_to_left, a:ignore_unmatched,
\ a:ignores, a:recursive)
if a:nth < max.tokens && (a:recur || len(a:modes) > 1)
call s:shift(a:modes, a:recur == 2)
call s:do_align(
\ a:modes, a:all_tokens, a:all_delims,
\ a:fl, a:ll, a:fc, a:lc, a:pattern,
\ a:nth + 1, a:ml, a:mr, a:da, a:indentation, a:stick_to_left,
\ a:ignore_unmatched, a:ignores, a:recur)
endif
endfunction
function! s:interactive(just)
let just = a:just
function! s:interactive(modes)
let mode = s:shift(a:modes, 1)
let n = ''
let ch = ''
while 1
call s:echon(just, n, '')
call s:echon(mode, n, '')
let c = getchar()
let ch = nr2char(c)
if c == 3 || c == 27 " CTRL-C / ESC
throw 'exit'
elseif c == '<27>kb' " Backspace
elseif c == "\<bs>"
if len(n) > 0
let n = strpart(n, 0, len(n) - 1)
endif
elseif c == 13 " Enter key
let just = (just + 1) % len(s:just)
let mode = s:shift(a:modes, 1)
elseif ch == '-'
if empty(n) | let n = '-'
elseif n == '-' | let n = ''
@@ -376,7 +475,7 @@ function! s:interactive(just)
break
endif
endwhile
return [just, n, ch]
return [mode, n, ch]
endfunction
function! s:parse_args(args)
@@ -394,8 +493,8 @@ function! s:parse_args(args)
let cand = strpart(args, midx)
try
let [l, r, c] = ['l', 'r', 'c']
let [L, R, C] = ['l', 'r', 'c']
let [l, r, c, k, s, d, n] = ['l', 'r', 'c', 'k', 's', 'd', 'n']
let [L, R, C, K, S, D, N] = ['l', 'r', 'c', 'k', 's', 'd', 'n']
let o = eval(cand)
if type(o) == 4
let option = o
@@ -433,8 +532,11 @@ function! s:parse_args(args)
endif
endfunction
function! easy_align#align(just, expr) range
let just = a:just
function! easy_align#align(bang, expr) range
let modes = get(g:,
\ (a:bang ? 'easy_align_bang_interactive_modes' : 'easy_align_interactive_modes'),
\ (a:bang ? ['r', 'l', 'c'] : ['l', 'r', 'c']))
let mode = modes[0]
let recur = 0
let n = ''
let ch = ''
@@ -443,10 +545,12 @@ function! easy_align#align(just, expr) range
try
if empty(a:expr)
let [just, n, ch] = s:interactive(just)
let [mode, n, ch] = s:interactive(copy(modes))
else
let [n, ch, option, regexp] = s:parse_args(a:expr)
if empty(ch)
if empty(n) && empty(ch)
let [mode, n, ch] = s:interactive(copy(modes))
elseif empty(ch)
" Try swapping n and ch
let [n, ch] = ['', n]
endif
@@ -504,15 +608,20 @@ function! easy_align#align(just, expr) range
if type(ml) == 0 | let ml = repeat(' ', ml) | endif
if type(mr) == 0 | let mr = repeat(' ', mr) | endif
let bvisual = visualmode() == ''
let bvisual = char2nr(visualmode()) == 22 " ^V
if recur && bvisual
echon "\rRecursive alignment is currently not supported in blockwise-visual mode"
return
endif
let aseq = get(dict, 'mode_sequence',
\ recur == 2 ? (mode == 'r' ? ['r', 'l'] : ['l', 'r']) : [mode])
try
call s:do_align(just, {}, {}, a:firstline, a:lastline,
call s:do_align(
\ type(aseq) == 1 ? split(tolower(aseq), '\s*') : map(copy(aseq), 'tolower(v:val)'),
\ {}, {}, a:firstline, a:lastline,
\ bvisual ? min([col("'<"), col("'>")]) : 1,
\ bvisual ? max([col("'<"), col("'>")]) : 0,
\ get(dict, 'pattern', ch),
@@ -520,11 +629,12 @@ function! easy_align#align(just, expr) range
\ ml,
\ mr,
\ get(dict, 'delimiter_align', get(g:, 'easy_align_delimiter_align', 'r')),
\ get(dict, 'indentation', get(g:, 'easy_align_indentation', 'k')),
\ get(dict, 'stick_to_left', 0),
\ get(dict, 'ignore_unmatched', get(g:, 'easy_align_ignore_unmatched', 1)),
\ get(dict, 'ignores', s:ignored_syntax()),
\ recur)
call s:echon(just, n, regexp ? '/'.ch.'/' : ch)
call s:echon(mode, n, regexp ? '/'.ch.'/' : ch)
catch 'exit'
endtry
endfunction

View File

@@ -3,23 +3,24 @@
vim-easy-align *vim-easy-align* *easy-align*
=========================================================================
A simple, easy-to-use Vim alignment plugin without too much ambition.
A simple, easy-to-use Vim alignment plugin.
Author: Junegunn Choi
Source: https://github.com/junegunn/vim-easy-align
Author: Junegunn Choi
Source: https://github.com/junegunn/vim-easy-align
License: MIT
EasyAlign *:EasyAlign* *:EasyAlign!*
-------------------------------------------------------------------------
vim-easy-align defines `:EasyAlign` command in the visual mode.
(:EasyAlign! is the right-justification version.)
(:EasyAlign! is the right-align version.)
| Mode | Command |
| ------------------------- | ------------------------------------------- |
| Interactive mode | :EasyAlign |
| Using predefined rules | :EasyAlign [FIELD#] DELIMITER_KEY [OPTIONS] |
| Using regular expressions | :EasyAlign [FIELD#] /REGEXP/ [OPTIONS] |
| Mode | Command |
| ------------------------- | ---------------------------------------------- |
| Interactive mode | :EasyAlign[!] [OPTIONS] |
| Using predefined rules | :EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS] |
| Using regular expressions | :EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS] |
Interactive mode
@@ -34,16 +35,16 @@ your `.vimrc`.
With this mapping, you can align selected lines of text with a few keystrokes.
1. <Enter> key to start interactive EasyAlign command
2. Optional Enter keys to switch justficiation mode (default: left)
2. Optional Enter keys to select alignment mode (left, right, or center)
3. Optional field number (default: 1)
1 Around the 1st occurrences of delimiters
2 Around the 2nd occurrences of delimiters
* Around all occurrences of delimiters
** Left-right alternating alignment around all delimiters
- Around the last occurrences of delimiters (`-1`)
- Around the last occurrences of delimiters (-1)
-2 Around the second to last occurrences of delimiters
...
4. Delimiter key (a single keystroke)
4. Delimiter key for the predefined rules (a single keystroke)
<space> General alignment around whitespaces
= Operators containing equals sign (=, ==, !=, +=, &&=, ...)
: Suitable for formatting JSON or YAML
@@ -51,7 +52,10 @@ With this mapping, you can align selected lines of text with a few keystrokes.
, Multi-line method arguments. CSV.
| Table markdown
During the key sequence, <Enter> key will toggle right-justification mode.
(You can override these default rules or define your own rules with
`g:easy_align_delimiters`, which will be described in the later section.)
During the key sequence, <Enter> key will toggle right-align mode.
Examples:
@@ -64,7 +68,7 @@ Examples:
<Enter>3= Alignment around 3rd equals signs (and the likes)
<Enter>*= Alignment around all equals signs (and the likes)
<Enter>**= Left-right alternating alignment around all equals signs
<Enter><Enter>= Right-justified alignment around 1st equals signs
<Enter><Enter>= Right-alignment around 1st equals signs
<Enter><Enter>**= Right-left alternating alignment around all equals signs
@@ -93,7 +97,7 @@ try these commands:
- :EasyAlign */[:;]\+/
- :EasyAlign **/[:;]\+/
Notice that you can't append `\zs` to your regular expression to put delimiters
Notice that you can't append '\zs' to your regular expression to put delimiters
on the left. It can be done by providing additional options in Vim dictionary
format.
@@ -104,7 +108,7 @@ Then we get:
apple;: banana:: cake
data;; exchange:; format
Options keys are fuzzy-matched, so you can write as follows:
Option names are fuzzy-matched, so you can write as follows:
- :EasyAlign * /[:;]\+/ { 'stl': 1, 'l': '' }
@@ -114,20 +118,25 @@ You can even omit spaces between the arguments, so concisely (or cryptically):
Available options are as follows.
| Atrribute | Type | Default |
| ---------------- | ---------------- | ----------------------- |
| left_margin | number or string | 0 |
| right_margin | number or string | 0 |
| stick_to_left | boolean | 0 |
| delimiter_align | string | 'r' |
| ignore_unmatched | boolean | 1 |
| ignores | array | `['String', 'Comment']` |
| Atrribute | Type | Default |
| ---------------- | ---------------- | ----------------------------- |
| left_margin | number or string | 0 |
| right_margin | number or string | 0 |
| stick_to_left | boolean | 0 |
| ignore_unmatched | boolean | 1 |
| ignores | array | ['String', 'Comment'] |
| delimiter_align | string | 'r' |
| | | (right, left, center) |
| indentation | string | 'k' |
| | | (keep, shallow, deep, none) |
| mode_sequence | string | (Depends on field number and |
| | | selected alignment mode) |
Partial alignment in blockwise-visual mode
-------------------------------------------------------------------------
In blockwise-visual mode (`CTRL-V`), EasyAlign command aligns only
In blockwise-visual mode (CTRL-V), EasyAlign command aligns only
the selected text in the block, instead of the whole lines in the range.
@@ -154,7 +163,7 @@ For example, the following paragraph
'grape:fruits': 3
}
becomes as follows on `<Enter>:`
becomes as follows on '<Enter>:' (or `:EasyAlign:`)
{
# Quantity of apples: 1
@@ -167,17 +176,13 @@ becomes as follows on `<Enter>:`
Naturally, this feature only works when syntax highlighting is enabled.
You can change the default rule by either defining global `g:easy_align_ignores`
array,
You can change the default rule by using one of these 3 methods.
" Ignore nothing!
let g:easy_align_ignores = []
1. Define global `g:easy_align_ignores` list
2. Define a custom rule in `g:easy_align_delimiters` with 'ignores' option
3. Provide 'ignores' option to `:EasyAlign` command. e.g. :EasyAlign:{'is':[]}
or providing `ignores` option directly to :EasyAlign command
:EasyAlign:{'is':[]}
Then you get,
For example if you set 'ignores' option to be an empty list, you get
{
# Quantity of apples: 1
@@ -193,7 +198,7 @@ Ignoring unmatched lines *g:easy_align_ignore_unmatched*
-------------------------------------------------------------------------
Lines without any matching delimiter are ignored as well (except in
right-justification mode).
right-align mode).
For example, when aligning the following code block around the colons,
@@ -215,17 +220,13 @@ this is usually what we want.
grapefruits: 3
}
However, this default behavior is also configurable.
One way is to set the global `g:easy_align_ignore_unmatched` variable to 0.
let g:easy_align_ignore_unmatched = 0
Or in non-interactive mode, you can provide `ignore_unmatched` option to
`:EasyAlign` command as follows.
:EasyAlign:{'iu':0}
However, this default behavior is also configurable by using one of these 3
methods.
1. Set the global `g:easy_align_ignore_unmatched` variable to 0
2. Define a custom alignment rule with 'ignore_unmatched' option set to 0
3. Provide 'ignore_unmatched' option to `:EasyAlign` command.
e.g. :EasyAlign:{'iu':0}
Then we get,
@@ -238,12 +239,11 @@ Then we get,
}
Aligning delimiters of different lengths *g:easy_align_delimiter_align*
-------------------------------------------------------------------------
Global `g:easy_align_delimiter_align` option and rule-wise/command-wise
`delimiter_align` option determines how matched delimiters of different
'delimiter_align' option determines how matched delimiters of different
lengths are aligned.
apple = 1
@@ -256,18 +256,137 @@ By default, delimiters are right-aligned as follows.
banana += apple
cake ||= banana
However, with `:EasyAlign={'da':l}`, delimiters are left-aligned.
However, with ':EasyAlign={'da':l}', delimiters are left-aligned.
apple = 1
banana += apple
cake ||= banana
And on `:EasyAlign={'da':c}`, center-aligned.
And on ':EasyAlign={'da':c}', center-aligned.
apple = 1
banana += apple
cake ||= banana
Adjusting indentation *g:easy_align_indentation*
-------------------------------------------------------------------------
By default :EasyAlign command keeps the original indentation of the lines.
But then again we have 'indentation' option. See the following example.
# Lines with different indentation
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Default: _k_eep the original indentation
# :EasyAlign=
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Use the _s_hallowest indentation among the lines
# :EasyAlign={'idt':s}
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Use the _d_eepest indentation among the lines
# :EasyAlign={'idt':d}
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
# Indentation: _n_one
# :EasyAlign={'idt':n}
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
Notice that 'idt' is fuzzy-matched to 'indentation'.
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
-------------------------------------------------------------------------
As stated above, "field number" is used to target specific occurrences of
the delimiter when it appears multiple times in each line.
To recap:
" Left-alignment around the FIRST occurrences of delimiters
:EasyAlign =
" Left-alignment around the SECOND occurrences of delimiters
:EasyAlign 2=
" Left-alignment around the LAST occurrences of delimiters
:EasyAlign -=
" Left-alignment around ALL occurrences of delimiters
:EasyAlign *=
" Left-right ALTERNATING alignment around all occurrences of delimiters
:EasyAlign **=
" Right-left ALTERNATING alignment around all occurrences of delimiters
:EasyAlign! **=
In addition to these, you can fine-tune alignments over multiple occurrences of
the delimiters with 'mode_sequence' option.
" Left alignment over the first two occurrences of delimiters
:EasyAlign = { 'mode_sequence': 'll' }
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
:EasyAlign = { 'm': 'rlc' }
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
:EasyAlign 2={ 'm': 'rlc' }
" (*) Repeating alignments (default: l, r, or c)
" Right, left, center, center, center, center, ...
:EasyAlign *={ 'm': 'rlc' }
" (**) Alternating alignments (default: lr or rl)
" Right, left, center, right, left, center, ...
:EasyAlign **={ 'm': 'rlc' }
Extending alignment rules *g:easy_align_delimiters*
-------------------------------------------------------------------------
@@ -280,7 +399,7 @@ you can extend the rules by setting a dictionary named
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignores': ['String'] },
\ '#': { 'pattern': '#\+', 'ignores': ['String'] },
\ ']': {
\ 'pattern': '[\[\]]',
\ 'pattern': '[[\]]',
\ 'left_margin': 0,
\ 'right_margin': 0,
\ 'stick_to_left': 0

View File

@@ -109,10 +109,10 @@ j, , k
bbbb = 2
ccccccc = 3
ccccccccccccccc
ddd = 4
ddd = #
eeee === eee = eee = eee=f
fff = ggg += gg &&= gg
g != hhhhhhhh == 888
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
@@ -134,10 +134,10 @@ a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
ddd = 4
ddd = #
eeee === eee = eee = eee = f
fff = ggg += gg &&= gg
g != hhhhhhhh == 888
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
@@ -159,10 +159,10 @@ a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
ddd = 4
ddd = #
eeee === eee = eee = eee = f
fff = ggg += gg &&= gg
g != hhhhhhhh == 888
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
@@ -184,10 +184,10 @@ a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
ddd = 4
ddd = #
eeee === eee = eee = eee=f
fff = ggg += gg &&= gg
g != hhhhhhhh == 888
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
@@ -355,15 +355,15 @@ my_object .
|batch_size |Fixnum |nil |number of maximum items to be assigned at once |
|logger |Logger |nil |logger instance for debug logs |
| Option <| Type <| Default<| Description <|
| -- <| -- <| -- <| -- <|
| threads <| Fixnum <| 1 <| number of threads in the thread pool <|
| queues <| Fixnum <| 1 <| number of concurrent queues <|
| queue_size<| Fixnum <| 1000 <| size of each queue <|
| interval <| Numeric<| 0 <| dispatcher interval for batch processing <|
| batch <| Boolean<| false <| enables batch processing mode <|
| batch_size<| Fixnum <| nil <| number of maximum items to be assigned at once<|
| logger <| Logger <| nil <| logger instance for debug logs <|
| Option ~| Type ~| Default~| Description ~|
| -- ~| -- ~| -- ~| -- ~|
| threads ~| Fixnum ~| 1 ~| number of threads in the thread pool ~|
| queues ~| Fixnum ~| 1 ~| number of concurrent queues ~|
| queue_size~| Fixnum ~| 1000 ~| size of each queue ~|
| interval ~| Numeric~| 0 ~| dispatcher interval for batch processing ~|
| batch ~| Boolean~| false ~| enables batch processing mode ~|
| batch_size~| Fixnum ~| nil ~| number of maximum items to be assigned at once~|
| logger ~| Logger ~| nil ~| logger instance for debug logs ~|
```c
@@ -374,10 +374,10 @@ static std::map<std::string, float>* scores = pointer;
```
Paul<<< McCartney{{{ 1942
George<<< Harrison {{{ 1943
Ringo<<< Starr {{{ 1940
Pete<<< Best {{{ 1941
Paul@@@ McCartney{{{ 1942
George@@@ Harrison {{{ 1943
Ringo@@@ Starr {{{ 1940
Pete@@@ Best {{{ 1941
Paul McCartney 1942
George Harrison 1943
@@ -504,3 +504,420 @@ George Harrison 1943
.. -- ......
... - .....-
apple = 1 = 2
banana = 2 = 2
cake = 3 = 2
daisy = 4 = 2
eggplant = 5 = 2
apple = 1 = 2
banana = 2 = 2
cake = 3 = 2
daisy = 4 = 2
eggplant = 5 = 2
apple = 1 = 2
banana = 2 = 2
cake = 3 = 2
daisy = 4 = 2
eggplant = 5 = 2
apple = 1 = 2
banana = 2 = 2
cake = 3 = 2
daisy = 4 = 2
eggplant = 5 = 2
apple = 1 = 2
banana = 2 = 2
cake = 3 = 2
daisy = 4 = 2
eggplant = 5 = 2
apple = 1 = 2
banana = 2 = 2
cake = 3 = 2
daisy = 4 = 2
eggplant = 5 = 2
1 apple = 1 = 2
1 banana = 2 = 2
1 cake = 3 = 2
1 daisy = 4 = 2
1 eggplant = 5 = 2
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
a pple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
apple = 1 = 2
banana = 2 = 2
cake = 3 = 2
daisy = 4 = 2
eggplant = 5 = 2
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
```c
int a = 1;
long b = 2;
float c = 3;
string d = 4;
// this line should not get aligned
long int e = 5;
std::map f;
std::map g; /* this? */
short h /* how about this? */ = 6;
string i = "asdf";
int a = 1;
long b = 2;
float c = 3;
string d = 4;
// this line should not get aligned
long int e = 5;
std::map f;
std::map g; /* this? */
short h /* how about this? */ = 6;
string i = "asdf";
```
```ruby
a =
a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
# eeeeeeeeeeeeeeee
e # asdf
ddd = #
eeee === eee = eee = eee=f
fff = ggg += gg &&= gg
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
j =~ 5
j >= 5
aa => 123
aa <<= 123
aa >>= 123
bbb => 123
c => 1233123
d => 123
dddddd &&= 123
dddddd ||= 123
dddddd /= 123
gg <=> ee
a =
a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
# eeeeeeeeeeeeeeee
e # asdf
ddd = #
eeee === eee = eee = eee = f
fff = ggg += gg &&= gg
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
j =~ 5
j >= 5
aa => 123
aa <<= 123
aa >>= 123
bbb => 123
c => 1233123
d => 123
dddddd &&= 123
dddddd ||= 123
dddddd /= 123
gg <=> ee
a =
a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
# eeeeeeeeeeeeeeee
e # asdf
ddd = #
eeee === eee = eee = eee = f
fff = ggg += gg &&= gg
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
j =~ 5
j >= 5
aa => 123
aa <<= 123
aa >>= 123
bbb => 123
c => 1233123
d => 123
dddddd &&= 123
dddddd ||= 123
dddddd /= 123
gg <=> ee
a =
a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
# eeeeeeeeeeeeeeee
e # asdf
ddd = #
eeee === eee = eee = eee = f
fff = ggg += gg &&= gg
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
j =~ 5
j >= 5
aa => 123
aa <<= 123
aa >>= 123
bbb => 123
c => 1233123
d => 123
dddddd &&= 123
dddddd ||= 123
dddddd /= 123
gg <=> ee
a =
a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
# eeeeeeeeeeeeeeee
e # asdf
ddd = #
eeee === eee = eee = eee = f
fff = ggg += gg &&= gg
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
j =~ 5
j >= 5
aa => 123
aa <<= 123
aa >>= 123
bbb => 123
c => 1233123
d => 123
dddddd &&= 123
dddddd ||= 123
dddddd /= 123
gg <=> ee
a =
a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
# eeeeeeeeeeeeeeee
e # asdf
ddd = #
eeee === eee = eee = eee=f
fff = ggg += gg &&= gg
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
j =~ 5
j >= 5
aa => 123
aa <<= 123
aa >>= 123
bbb => 123
c => 1233123
d => 123
dddddd &&= 123
dddddd ||= 123
dddddd /= 123
gg <=> ee
a = 1
bb = 22
ccc = 333
dddd = "asdf"
a = 1
bb = 22
ccc = 333
dddd = "asdf"
a = 1
bb = 22
ccc = 333
dddd = "asdf"
a = 1
bb = 22
ccc = 333
dddd = "asdf"
a = 1
bb = 22
ccc = 333
dddd = "asdf"
a = 1
bb = 22
ccc = 333
dddd = "asdf"
a = 1
bb = 22
ccc = 333
dddd = "asdf"
```
a a a a a
bbb bbb bbb bbb bbb
ccccc ccccc ccccc ccccc ccccc
d ddd dddd ddd d
aaaaa = 123456778901234567890 =
bbbbbbbbbb = 12345 =
aaaaa = 123456778901234567890 =
cccccccccccccccccc = 123 =
aaaaa = 123456778901234567890 =
cccccccccccccccccc = 12345678 =
aaaaa = 12345 =
bbbbbbbbbb = 123456778901234567890 =
aaaaa = 12345
bbbbbbbbbb = 123456778901234567890
123456 789
1234567890 1
1234 56
123456 7890
aaaaa = 123456778901234567890 =
cccccccccccccccccc = 12345678 =
| Option | Type | Default | Description |
| -- | -- | -- | -- |
| threads | Fixnum | 1 | number of threads in the thread pool |
| queues | Fixnum | 1 | number of concurrent queues |
| queue_size | Fixnum | 1000 | size of each queue |
| interval | Numeric | 0 | dispatcher interval for batch processing |
| batch | Boolean | false | enables batch processing mode |
| batch_size | Fixnum | nil | number of maximum items to be assigned at once |
| logger | Logger | nil | logger instance for debug logs |
| Option | Type | Default | Description |
| -- | -- | -- | -- |
| threads | Fixnum | 1 | number of threads in the thread pool |
| queues | Fixnum | 1 | number of concurrent queues |
| queue_size | Fixnum | 1000 | size of each queue |
| interval | Numeric | 0 | dispatcher interval for batch processing |
| batch | Boolean | false | enables batch processing mode |
| batch_size | Fixnum | nil | number of maximum items to be assigned at once |
| logger | Logger | nil | logger instance for debug logs |
| Option | Type | Default | Description |
| -- | -- | -- | -- |
| threads | Fixnum | 1 | number of threads in the thread pool |
| queues | Fixnum | 1 | number of concurrent queues |
| queue_size | Fixnum | 1000 | size of each queue |
| interval | Numeric | 0 | dispatcher interval for batch processing |
| batch | Boolean | false | enables batch processing mode |
| batch_size | Fixnum | nil | number of maximum items to be assigned at once |
| logger | Logger | nil | logger instance for debug logs |
Option | Type | Default | Description |
-- | -- | -- | -- |
threads | Fixnum | 1 | number of threads in the thread pool |
queues | Fixnum | 1 | number of concurrent queues |
queue_size | Fixnum | 1000 | size of each queue |
interval | Numeric | 0 | dispatcher interval for batch processing |
batch | Boolean | false | enables batch processing mode |
batch_size | Fixnum | nil | number of maximum items to be assigned at once |
logger | Logger | nil | logger instance for debug logs |

View File

@@ -29,10 +29,10 @@ a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
ddd = 4
ddd = #
eeee === eee = eee = eee=f
fff = ggg += gg &&= gg
g != hhhhhhhh == 888
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
@@ -130,3 +130,90 @@ Pete Best 1941
..--......
...-.....-
apple = 1
banana = 2
cake = 3
daisy = 4
eggplant = 5
```c
int a = 1;
long b = 2;
float c = 3;
string d = 4;
// this line should not get aligned
long int e = 5;
std::map f;
std::map g; /* this? */
short h /* how about this? */ = 6;
string i = "asdf";
```
```ruby
a =
a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
# eeeeeeeeeeeeeeee
e # asdf
ddd = #
eeee === eee = eee = eee=f
fff = ggg += gg &&= gg
g != hhhhhhhh == # 8
i := 5
i %= 5
i *= 5
j =~ 5
j >= 5
aa => 123
aa <<= 123
aa >>= 123
bbb => 123
c => 1233123
d => 123
dddddd &&= 123
dddddd ||= 123
dddddd /= 123
gg <=> ee
a = 1
bb = 22
ccc = 333
dddd = "asdf"
```
a a a a a
bbb bbb bbb bbb bbb
ccccc ccccc ccccc ccccc ccccc
d ddd dddd ddd d
aaaaa = 123456778901234567890 =
bbbbbbbbbb = 12345 =
aaaaa = 123456778901234567890 =
cccccccccccccccccc = 123 =
aaaaa = 123456778901234567890 =
cccccccccccccccccc = 12345678 =
aaaaa = 12345 =
bbbbbbbbbb = 123456778901234567890 =
aaaaa = 12345
bbbbbbbbbb = 123456778901234567890
123456 789
1234567890 1
1234 56
123456 7890
aaaaa = 123456778901234567890 =
cccccccccccccccccc = 12345678 =

View File

@@ -1 +1 @@
4Gvipjyvip
4Gvipjyvip

View File

@@ -37,6 +37,7 @@ vnoremap <silent> <C-l> <nop>
set nolazyredraw
set buftype=nofile
set colorcolumn=
silent! ScrollPositionHide

View File

@@ -91,6 +91,6 @@ apricot = 'DAD' + 'F#AD'
banana = 'Gros Michel' # comment 2
```
a()p()p()l()e();():()b()a()n()a()n()a():():()c()a()k()e
d()a()t()a();();()e()x()c()h()a()n()g()e():();()f()o()r()m()a()t
a()p()p()l()e();():()b()a()n()a()n()a():():()c()a()k()e(
d()a()t()a();();()e()x()c()h()a()n()g()e():();()f()o()r()m()a()t(