184 Commits

Author SHA1 Message Date
j-xella
9815a55dbc Resolve syntax highlighting group in neovim/treesitter (#160)
Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>
2024-04-13 12:21:42 +09:00
Michael Gaffney
12dd631697 Allow 'easy-align.txt' to be listed in the LOCAL ADDITIONS section of help.txt
The first field on the first line of a help file should be a link to the
help file name. (See :h help-writing)
2019-04-29 13:32:31 +09:00
Junegunn Choi
1cd724dc23 Fix invalid detection of blockwise visual mode
Close #105
2017-06-03 22:10:13 +09:00
Junegunn Choi
14c693dfe5 Merge pull request #104 from D4D3VD4V3/patch-1
Fixed typo in docs
2017-06-01 01:15:46 +09:00
Dave
d3f8e64261 Fixed typo in docs 2017-05-31 21:18:52 +05:30
Junegunn Choi
3b395bd5ba Merge pull request #99 from yanma/default_nth
Add g:easy_align_nth to allow configuring default nth
2017-02-08 00:38:53 +09:00
Hiroaki Yamazoe
05cc60d222 add test case for g:easy_align_nth 2017-02-08 00:30:52 +09:00
Hiroaki Yamazoe
4be4101ad5 add g:easy_align_nth to allow configuring default nth 2017-02-04 19:57:39 +09:00
Junegunn Choi
3800a5405c Merge pull request #98 from jan-warchol/master
Fix typos in README.md
2017-01-28 11:09:55 +09:00
Jan Warchoł
2e27fe55ad Fix typos in README.md 2017-01-27 22:38:48 +01:00
Junegunn Choi
0cb6b98fc1 Use search pattern as delimiter if empty regex is given
Close #78
2016-03-06 13:47:17 +09:00
Junegunn Choi
dd98d0a895 Add " rule for vim comments
Related: #76
2016-02-05 11:06:00 +09:00
Junegunn Choi
d1b68f9dd0 Undo when LiveEasyAlign is cancelled via CTRL-C 2016-01-26 00:57:54 +09:00
Junegunn Choi
4fb4c1056c Clear command-line or restore visual selection on interrupt
Close #74
2016-01-26 00:52:09 +09:00
Junegunn Choi
7cb559eb70 Update EXAMPLES.md 2015-10-09 23:02:47 +09:00
Junegunn Choi
9ebd0e82da Remove DEMO.md 2015-10-09 22:27:43 +09:00
Junegunn Choi
9e6207246c Update README 2015-10-09 22:02:02 +09:00
Junegunn Choi
4732f10155 Update README 2015-10-09 18:42:19 +09:00
Junegunn Choi
cd124c2c0b Merge pull request #70 from junegunn/doc-update
Update README (#68)
2015-10-09 18:29:35 +09:00
Junegunn Choi
ed65b47f1b Update README (#68)
- Split the long demo into short gifs
- Clarify the modes of execution
2015-10-09 18:27:02 +09:00
Junegunn Choi
fac9f4dd75 Fix failing test case 2015-10-09 18:23:51 +09:00
Junegunn Choi
0db4ea6132 Use virtcol in blockwise visual mode 2015-10-01 19:32:36 +09:00
Junegunn Choi
504eab0f59 Change split logic to allow advanced patterns
- \v  (Fix #67)
- \zs (Fix #55)
2015-10-01 19:26:46 +09:00
Junegunn Choi
98e0b493ac Apply filter option to substrings in blockwise-visual mode 2015-09-16 03:08:08 +09:00
Junegunn Choi
1206c65dcb Fix regular expression for = rule
Bug reported by @cvlmtg
2015-07-20 00:39:09 +09:00
Junegunn Choi
a1118be7d9 Extend default = rule to include ?=
Close #65
2015-07-15 21:57:33 +09:00
Junegunn Choi
c62d124be6 Update help file 2014-12-14 02:48:28 +09:00
Junegunn Choi
883c6b67a0 Add regression test case for #51 2014-12-10 12:01:39 +09:00
Junegunn Choi
32591ec4d4 Merge branch 'wilywampa-fixrepeat' 2014-12-10 11:53:28 +09:00
Jacob Niehus
ac9aa14ae4 Fix repeat of visual LiveEasyAlign 2014-12-09 19:41:39 -07:00
Junegunn Choi
cafe55dd65 Fix #50 - Updated shorthand notation (m -> a) 2014-12-09 15:25:44 +09:00
Junegunn Choi
6c276c37ad Add failing test case for #50 2014-12-09 15:23:46 +09:00
Junegunn Choi
1744414e7e Update README 2014-12-08 17:34:12 +09:00
Junegunn Choi
246139c57c Remove dead code (Fix #47)
Thanks to @itchyny
2014-12-01 19:26:28 +09:00
Junegunn Choi
3afd4540ed Fix #46: Remove duplicate tags 2014-12-01 01:04:04 +09:00
Junegunn Choi
2782c1d0db Fix <CTRL-P> to toggle liveness when delimiter is not entered (#44) 2014-11-30 11:34:32 +09:00
Junegunn Choi
d983381a99 Merge branch 'master' of github.com:junegunn/vim-easy-align 2014-11-30 02:03:36 +09:00
Junegunn Choi
52814ccd96 Update License 2014-11-30 02:03:13 +09:00
Junegunn Choi
aa1ba68ea0 Retain cursor position after <Plug>(EasyAlign) in visual mode 2014-11-30 02:01:52 +09:00
Junegunn Choi
b8abc366a6 Fix code indentation 2014-11-30 01:46:11 +09:00
Junegunn Choi
f6586bad39 <CTRL-P> to switch to live interactive mode (#44) 2014-11-30 01:45:27 +09:00
Junegunn Choi
44216b0a2c Do nothing when nomodifiable (#43) 2014-11-23 03:39:33 +09:00
Junegunn Choi
2595ebf933 Oops, remove duplicate line from the previous commit (#40) 2014-10-03 11:29:03 +09:00
Junegunn Choi
6bc221c285 Fix #40: Spurious undo in live interactive mode
Problem identified and patch provided by @wilywampa
2014-10-03 11:25:51 +09:00
Junegunn Choi
21697776b4 Allow recursive alignment (*, **) in blockwise-visual mode
Recursive alignment in blockwise-visual mode will align around all the
delimiters found after the start of the block. This behavior is
inconsistent with non-recursive alignment where the delimiters after the
end of the block are ignored. Making it respect the end of the block is
non-trivial and may not be intuitive as each alignment will change the
position of the delimiters inside the block and some of them will end up
beyond the scope of the block.
2014-09-13 19:54:49 +09:00
Junegunn Choi
09167c79c9 Fix travis-ci build 2014-09-08 16:30:45 +09:00
Junegunn Choi
cbb005ee71 Update the link to the default alignment rules 2014-08-14 14:29:34 +09:00
Junegunn Choi
ec15731bc9 Update README: Shorthand notation for stick_to_left option 2014-08-14 14:14:22 +09:00
Junegunn Choi
eee4735770 Update shorthand notation for stick_to_left: > to unset
- `<` == `stl1`
- `>` == `stl0`
2014-08-14 12:38:44 +09:00
Junegunn Choi
5e2a588403 Update README 2014-07-23 22:17:40 +09:00
Junegunn Choi
2fa6a040f6 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.
2014-07-23 22:15:01 +09:00
Junegunn Choi
f9a49e441d Preserve last selection when using <Plug>(EasyAlign) 2014-06-27 23:31:22 +09:00
Junegunn Choi
fc9555cd65 Allow negation operator in ignore_groups option
e.g. ig['!String']
2014-06-24 00:09:51 +09:00
Junegunn Choi
a98c1ccc99 Add '#'-rule (#30)
For Ruby/Python comments. This new '#' rule will only match
'#' characters that are highlighted as comments.
2014-06-20 10:36:37 +09:00
Junegunn Choi
0aa6289d8c Update EXAMPLES.md 2014-06-08 00:36:07 +09:00
Junegunn Choi
cc8966c0a5 Update README 2014-05-31 02:59:14 +09:00
Junegunn Choi
da281d78d3 Update document 2014-05-31 00:50:25 +09:00
Junegunn Choi
8e8629c0cd Export-ignore .travis.yml 2014-05-16 11:56:25 +09:00
Junegunn Choi
a9f593fdf8 Update test runner 2014-05-09 00:55:28 +09:00
Junegunn Choi
d87ea32cfe Update .travis.yml 2014-04-28 13:44:45 +09:00
Junegunn Choi
11a6b03e7e Add .travis.yml 2014-04-28 13:25:20 +09:00
Junegunn Choi
ba54df53ca Better handling of tab characters using strdisplaywidth 2014-04-11 10:39:39 +09:00
Junegunn Choi
d041e17bba Update README 2014-03-19 19:10:53 +09:00
Junegunn Choi
2ab86911cb Update README 2014-03-19 19:06:03 +09:00
Junegunn Choi
4929841a7a Remove +float dependency 2014-01-20 01:30:31 +09:00
Junegunn Choi
12792cd60f Simplify tests using Include: directive 2014-01-19 11:32:52 +09:00
Junegunn Choi
f7213f30f3 Update README
- Changed maps to LiveEasyAlign
2013-12-22 15:19:58 +09:00
Junegunn Choi
f44c325aa2 Merge branch 'master' of github.com:junegunn/vim-easy-align 2013-12-21 16:47:27 +09:00
Junegunn Choi
dc4786841e Workaround for Vim bug: using Float as a String in gvim (#27) 2013-12-19 10:20:04 +09:00
Junegunn Choi
46abd8fb92 Add set cpo&vim for compatible mode 2013-12-19 10:04:03 +09:00
Junegunn Choi
af39e544ca set cpo&vim for compatible mode 2013-12-19 00:53:05 +09:00
Junegunn Choi
49c7133328 Update documentation 2013-12-11 00:53:03 +09:00
Junegunn Choi
4298395085 Extract tags from code block as well 2013-12-08 19:11:43 +09:00
Junegunn Choi
e7fca89dde Update helpdoc
- Change heading format
2013-12-08 10:35:56 +09:00
Junegunn Choi
4b706efeb3 Fix helpfile 2013-12-08 00:48:59 +09:00
Junegunn Choi
9bb987599a Tags for ToC 2013-12-08 00:36:18 +09:00
Junegunn Choi
b8e93f96b8 Convert current README.md into helpfile. Added TOC (#22) 2013-12-08 00:14:50 +09:00
Junegunn Choi
6d85e93476 Make repeatable in visual mode 2013-12-06 02:11:57 +09:00
Junegunn Choi
9271fc3f8f Make visual-operator repeatable (#24) 2013-12-05 23:16:33 +09:00
Junegunn Choi
d3eec7fa8b Remove an unnecessary function call 2013-12-05 20:50:46 +09:00
Junegunn Choi
62387b78e0 Fix normal-mode repeat affected by visual-mode operator 2013-12-05 13:36:01 +09:00
Junegunn Choi
f400e4d8d1 Wording 2013-12-03 02:27:30 +09:00
Junegunn Choi
9716fb3917 One-minute guide 2013-12-03 02:25:40 +09:00
Junegunn Choi
353ae9b071 One-minute guide 2013-12-03 02:21:05 +09:00
Junegunn Choi
ba4ba6e3c4 Fix vim-repeat integration 2013-12-02 00:33:33 +09:00
Junegunn Choi
da284f908e <Plug>(EasyAlign) / <Plug>(LiveEasyAlign) for vim-repeat integration 2013-12-01 22:58:13 +09:00
Junegunn Choi
8d4d5b7941 Update documentation 2013-11-30 13:07:26 +09:00
Junegunn Choi
165bda1d95 Add <Plug>(EasyAlignOperator) 2013-11-30 13:04:32 +09:00
Junegunn Choi
ddc1e00b81 Update README
- Add <silent> to opfunc mapping
2013-11-30 11:55:54 +09:00
Junegunn Choi
462a800064 Generic operator function with interactive mode 2013-11-30 11:41:11 +09:00
Junegunn Choi
3921d0bab3 Fix #20 - Alignment with tabs inserting spaces 2013-11-20 07:27:39 +09:00
Junegunn Choi
ea1ea51ef1 Fix link to slow GIF 2013-11-15 02:27:14 +09:00
Junegunn Choi
2daae46a43 Fix indentation option to work with hard tabs (#19) 2013-10-31 12:32:07 +09:00
Junegunn Choi
2b119f9bb6 Fix issue #19 (hard tab indentation) 2013-10-31 11:08:02 +09:00
Junegunn Choi
15bcbc9499 Update readme 2013-10-29 23:24:14 +09:00
Junegunn Choi
54e6b5d866 Update screenshot 2013-10-29 22:17:23 +09:00
Junegunn Choi
1f28ce346e Update README 2013-10-27 03:14:40 +09:00
Junegunn Choi
2832a76cea Implement filter option (#16, #17)
This commit implements filter option which can be used to filter lines within
the range based on the given pattern. The value of filter option should be
either `g/pattern/` or `v/pattern/`. The former aligns lines that match the
pattern, the latter aligns lines that do not match the pattern.
2013-10-27 03:10:04 +09:00
Junegunn Choi
1a232ac19b Revert "Make user confirm regular expression on live interactive mode"
This reverts commit a76cfdb8ae.
2013-10-25 02:17:52 +09:00
Junegunn Choi
a76cfdb8ae Make user confirm regular expression on live interactive mode 2013-10-25 02:11:43 +09:00
Junegunn Choi
c3a7842b0d Remove a redundant Expect block 2013-10-22 11:24:46 +09:00
Junegunn Choi
3cc564bd68 Do not attach margin_left string before phantom token 2013-10-19 19:49:11 +09:00
Junegunn Choi
6e2264672a Implement live interactive mode (#15)
This commit adds LiveEasyAlign command. (The name was chosen not to introduce
ambiguity when typing in only the prefix of the command: e.g. `:EasyA*|`)
In live interactive mode, the selected text is aligned on-the-fly as the user
type in. In order to finalize the alignment, the user has to type in the
same delimiter key again. (Or CTRL-X on regular expressions)
2013-10-19 19:21:23 +09:00
Junegunn Choi
bec3e94383 Log g:easy_align_last_command 2013-10-18 18:05:52 +09:00
Junegunn Choi
7f0fccba0b Update README 2013-10-15 23:08:16 +09:00
Junegunn Choi
aa62ca4603 Update documentation 2013-10-15 23:07:14 +09:00
Junegunn Choi
831cecdaf2 Implement g:easy_align_bypass_fold switch (#14) with a small fix 2013-10-15 23:00:43 +09:00
Junegunn Choi
37fa908d04 Remove s:max function
Sadly function calls are rather slow in Vimscript.
Test shows that this commit reduces the response time by 10%.
2013-10-13 12:16:58 +09:00
Junegunn Choi
256e5b83ab Remove recursion not to fail in case of many delimiters (> maxfuncdepth) 2013-10-13 03:31:05 +09:00
Junegunn Choi
cb7306341c Use function() instead of a forwarding function 2013-10-13 02:10:33 +09:00
Junegunn Choi
7b82a1e496 Fix: right margin sometimes not attached in partial alignment 2013-10-13 02:09:06 +09:00
Junegunn Choi
ad2df21039 Add alignment rule for LaTeX tables (#13) 2013-10-10 22:15:23 +09:00
Junegunn Choi
4c2808d13c Relocate operator section 2013-10-10 16:04:48 +09:00
Junegunn Choi
124654ec46 Update test doc 2013-10-10 12:58:27 +09:00
Junegunn Choi
ab4b72addf Update README 2013-10-10 12:55:00 +09:00
Junegunn Choi
cdc648f5a4 EasyAlign command as Vim operator 2013-10-10 12:51:43 +09:00
Junegunn Choi
438b5312ee Thoroughly tested 2013-10-10 00:33:32 +09:00
Junegunn Choi
e24f8479a5 Fix invalid test case 2013-10-10 00:19:54 +09:00
Junegunn Choi
9d626dd765 Add test cases for ignore_unmatched behavior 2013-10-10 00:18:52 +09:00
Junegunn Choi
7490aa61d7 Merge pull request #12 from junegunn/vader
Testing with Vader.vim
2013-10-09 08:06:51 -07:00
Junegunn Choi
aa42666f10 Remove recording-based test for interactive mode 2013-10-10 00:03:21 +09:00
Junegunn Choi
9951cad2d0 Rename README 2013-10-09 22:18:38 +09:00
Junegunn Choi
cb5041ba67 Merge branch 'master' into vader 2013-10-09 22:18:20 +09:00
Junegunn Choi
7019edb08c More test cases on Vader 2013-10-09 22:11:03 +09:00
Junegunn Choi
247f69bf3f Migrate more test cases to Vader 2013-10-09 20:39:17 +09:00
Junegunn Choi
133588b181 Testing with Vader.vim 2013-10-09 20:16:58 +09:00
Junegunn Choi
fb8cf1d54a Update doc 2013-10-08 10:59:17 +09:00
Junegunn Choi
013fb54dd1 Update documentation 2013-10-07 21:13:17 +09:00
Junegunn Choi
2bf1b2164d Allow shorthand option notation when using delimiter key
e.g. :EasyAlign=l2r2dlmlr**
2013-10-07 21:09:37 +09:00
Junegunn Choi
bab23a1917 Update documentation 2013-10-05 15:55:22 +09:00
Junegunn Choi
fa26fd7b42 Remove option value after every cycle 2013-10-05 15:27:50 +09:00
Junegunn Choi
a4a1e27395 Apply ignore_unmatched option on R/C mode if explicitly set
By default, unmatched trailing token from each line is also aligned in
right and center alignment modes unlike in left alignment mode. If
ignore_unmatched option is explicitly set to 1 by user, they will be ignored
even in right/center modes.
2013-10-05 12:23:44 +09:00
Junegunn Choi
98bd9fe6f0 Shorthand notation for ignore_groups/ignore_unmatched
e.g. ig['String']iu0
2013-10-04 02:29:24 +09:00
Junegunn Choi
f944f5bf29 Set g:easy_align_last_command 2013-10-04 02:07:35 +09:00
Junegunn Choi
484b4ba5ec Update doc 2013-10-04 01:50:43 +09:00
Junegunn Choi
9d3afa6206 Merge option values in dictionary and shortcut expression 2013-10-04 01:36:55 +09:00
Junegunn Choi
4c6a8c174d Implement shortcut expression for options 2013-10-03 21:59:51 +09:00
Junegunn Choi
3304f4e95a Make <Down> set both left and right margin to zero
(Undocumented) <Up> will clear *UP* left_margin, right_margin, and stick_to_left
2013-10-03 16:06:23 +09:00
Junegunn Choi
e4f86274e3 Update install instructions 2013-09-22 23:04:20 +09:00
Junegunn Choi
2d575bcc25 Underscore between parens 2013-09-22 22:56:27 +09:00
Junegunn Choi
8a783c2125 Fix a failure in test due to change in interactive mode 2013-09-22 22:21:23 +09:00
Junegunn Choi
5230a2402f Disallow 0 as the first character of N-th 2013-09-22 21:58:31 +09:00
Junegunn Choi
94a750e03e Remove unnecessary prev output wipe 2013-09-22 21:48:14 +09:00
Junegunn Choi
afc95b5ed7 Forgiving interactive mode: Do not terminate on invalid input 2013-09-22 21:17:02 +09:00
Junegunn Choi
1d2c58c06a Field index -> N-th parameter 2013-09-22 03:52:36 +09:00
Junegunn Choi
4cdc450126 Update DEMO.md 2013-09-21 23:53:47 +09:00
Junegunn Choi
7e1be152dc Add DEMO.md 2013-09-21 15:46:40 +09:00
Junegunn Choi
c61a11d150 Update doc
- Field number -> Field index
2013-09-21 13:08:55 +09:00
Junegunn Choi
2797baca6c Disallow non-printable character input 2013-09-21 12:04:56 +09:00
Junegunn Choi
663264ed39 Fix center-alignment
= = eee   = eee = f
= = gg  &&= gg
= = fff

= = eee   = eee = f
= = gg  &&= gg
= = f f
2013-09-21 03:31:34 +09:00
Junegunn Choi
df75520f72 Colored, replayable output 2013-09-21 03:11:20 +09:00
Junegunn Choi
a2d52611ee Fix invalid type conversion 2013-09-20 23:19:32 +09:00
Junegunn Choi
fce0a103ff Use try-finally for reverting the setup 2013-09-19 17:27:26 +09:00
Junegunn Choi
1752bf567b Improve message output
- Error message highlighting
- Wipe previous message if needed
- No line wrap on narrow terminal
2013-09-19 17:10:00 +09:00
Junegunn Choi
003194a47f Update example command sequences 2013-09-18 16:18:03 +09:00
Junegunn Choi
c1c6f32e8c Update example command sequence 2013-09-18 15:50:19 +09:00
Junegunn Choi
71edb17182 Update help file 2013-09-17 23:36:58 +09:00
Junegunn Choi
8951e13cf8 Update documentation 2013-09-17 23:32:41 +09:00
Junegunn Choi
a998aee45d Update README.md 2013-09-17 15:57:41 +09:00
Junegunn Choi
912bf6ca93 Update README.md 2013-09-17 15:54:33 +09:00
Junegunn Choi
9cf4fde00c Use number as margins (same effect, but easier to read) 2013-09-17 03:12:30 +09:00
Junegunn Choi
5f5cd49e95 Update README.md 2013-09-17 03:05:43 +09:00
Junegunn Choi
639ade715b Wording 2013-09-15 19:59:36 +09:00
Junegunn Choi
a1f2a697a5 Update README 2013-09-15 19:49:26 +09:00
Junegunn Choi
0fb127cee6 Update doc 2013-09-15 01:28:42 +09:00
Junegunn Choi
d3803b927d Heuristically determine if the user was in visual mode 2013-09-14 23:15:03 +09:00
Junegunn Choi
40a06e3d36 Left arrow key will also set left_margin to zero
- Right arrow key will set left_margin to one
- Up and Down arrow will clear the values of stick_to_left and left_margin
2013-09-14 17:30:51 +09:00
Junegunn Choi
11e0623959 DASH, not LI 2013-09-14 17:23:08 +09:00
Junegunn Choi
e9b6418280 Concept of alignment rule 2013-09-14 17:20:14 +09:00
Junegunn Choi
9f9d18ca71 Fix #8, #9, and #10.
- <Left> and <Right> key to toggle stick_to_left option
- <CTRL-X> in addition to <CTRL-/> to take regular expression
- Retain visual selection display on <CTRL-O/L/R/X>
2013-09-14 12:31:01 +09:00
Junegunn Choi
301bdbcfc7 Regular expression in interactive mode (#8) 2013-09-14 00:40:16 +09:00
Junegunn Choi
56e498a57d Implement mode_sequence expansion (#7) 2013-09-14 00:05:08 +09:00
Junegunn Choi
c0a500728c Update README 2013-09-13 10:34:16 +09:00
Junegunn Choi
2e0f9a73cd Update README.md 2013-09-13 10:26:38 +09:00
Junegunn Choi
6cac16dc3d Include =~# and =~? in = rule (Vimscript) 2013-08-25 23:03:30 +09:00
Junegunn Choi
6b275b8a46 Revert C-style variable definition example 2013-08-23 17:55:35 +09:00
Junegunn Choi
25fec2e955 Implement stick_to_left in center-alignment mode 2013-08-23 17:47:03 +09:00
Junegunn Choi
01337b9c4e Include .= operator in = rule 2013-08-23 17:40:13 +09:00
Junegunn Choi
0f70b20fdb Add related work section (#6) 2013-08-23 13:14:03 +09:00
Junegunn Choi
61be5b3abf Update doc 2013-08-23 01:37:50 +09:00
Junegunn Choi
2ad49b24f0 Add CTRL-O special key for mode_sequence option 2013-08-23 00:09:21 +09:00
Junegunn Choi
5058de6f4c Retain lm and rm values on CTRL-L and CTRL-R 2013-08-22 23:47:25 +09:00
Junegunn Choi
4c5d6d9e82 Improve center-alignment: ignore leading whitespaces 2013-08-22 23:41:21 +09:00
Junegunn Choi
12c319a8ac Implement special keys to switch option values in interactive mode
With this commit, we can now change option values in interactive mode with the
folowing special keys

- CTRL-L  left_margin
- CTRL-R  right_margin
- CTRL-D  delimiter_align
- CTRL-I  indentation
- CTRL-U  ignore_unmatched
- CTRL-G  ignore_groups

('ignores' option has been renamed to 'ignore_groups', but backward-compatible)
2013-08-20 01:38:20 +09:00
26 changed files with 4697 additions and 1964 deletions

1
.gitattributes vendored
View File

@@ -1,3 +1,4 @@
.travis.yml export-ignore
.gitattributes export-ignore
.gitignore export-ignore
doc/tags export-ignore

15
.travis.yml Normal file
View File

@@ -0,0 +1,15 @@
language: vim
before_script: |
git clone https://github.com/junegunn/vader.vim.git
git clone https://github.com/tpope/vim-repeat
script: |
vim -Nu <(cat << VIMRC
filetype off
set rtp+=vader.vim
set rtp+=vim-repeat
set rtp+=.
filetype plugin indent on
syntax enable
VIMRC) -c 'Vader! test/*' > /dev/null

View File

@@ -1,14 +1,23 @@
vim-easy-align examples
=======================
easy-align examples
===================
Open this document in your Vim and try it yourself.
This document assumes that you have defined the following mapping.
This document assumes that you have the following mappings in your .vimrc.
```vim
vnoremap <silent> <Enter> :EasyAlign<cr>
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
```
You can use either of the maps. Place the cursor on the paragraph and press
- `gaip` "(ga) start easy-align on (i)nner (p)aragraph"
- or `vipga` "(v)isual-select (i)nner (p)aragraph and (ga) start easy-align"
To enable syntax highlighting in the code blocks, define and call the following
function.
@@ -33,15 +42,17 @@ Alignment around whitespaces
You can align text around whitespaces with `<space>` delimiter key.
Try these commands:
Start the interactive mode as described above (`gaip` or `vipga`) and try
these commands:
- `<space>`
- `2<space>`
- `*<space>`
- `-<space>`
- `-2<space>`
- `<Enter><space>`
- `<Enter>2<space>`
- `<Enter>*<space>`
- `<Enter>-<space>`
- `<Enter>-2<space>`
- `<Enter><Enter><space>`
- `<Enter><Enter>*<space>`
- `<Enter><Enter><Enter>*<space>`
### Example
@@ -57,12 +68,13 @@ Pete Best 1941
Formatting table
----------------
Try these commands:
Again, start the interactive mode and try these commands:
- `*|`
- `**|`
- `<Enter>*|`
- `<Enter>**|`
- `<Enter><Enter>*|`
- `<Enter><Enter>**|`
- `<Enter><Enter><Enter>*|`
### Example
@@ -84,15 +96,16 @@ Try these commands:
Alignment around =
------------------
The default rule for delimiter key `=` aligns around a whole family of operators
containing `=` character.
The default rule for delimiter key `=` aligns around a whole family of
operators containing `=` character.
Try these commands:
- `<Enter>=`
- `<Enter>*=`
Try these commands in the interactive mode.
- `=`
- `*=`
- `**=`
- `<Enter>**=`
- `<Enter><Enter>**=`
- `<Enter><Enter><Enter>*=`
- `<Enter><Enter>*=`
### Example
@@ -128,8 +141,8 @@ gg <=> ee
Formatting YAML (or JSON)
-------------------------
Try `<Enter>:` here, to align text around only the first occurrences of colons.
In this case, you don't want to align around all the colons: `<Enter>*:`.
You can use `:`-rule here to align text around only the first occurrences of
colons. In this case, you don't want to align around all the colons: `*:`.
```yaml
mysql:
@@ -144,7 +157,7 @@ mysql:
Formatting multi-line method chaining
-------------------------------------
Try `<Enter>.` or `<Enter>*.` on the following lines.
Try `.` or `*.` on the following lines.
```ruby
my_object
@@ -166,12 +179,12 @@ my_object
```
Using blockwise-visual mode or negative field index
---------------------------------------------------
Using blockwise-visual mode or negative N-th parameter
------------------------------------------------------
You can try either:
- select text around `=>` in blockwise-visual mode (`CTRL-V`) and `<Enter>=`
- or `<Enter>-=`
- select text around `=>` in blockwise-visual mode (`CTRL-V`) and `ga=`
- or `gaip-=`
```ruby
options = { :caching => nil,
@@ -182,8 +195,7 @@ options = { :caching => nil,
Commas
------
There is also a predefined rule for commas, try `<Enter>*,` on the following
lines.
There is also a predefined rule for commas, try `*,`.
```
aaa, bb,c
@@ -197,7 +209,7 @@ Ignoring delimiters in comments or strings
------------------------------------------
Delimiters highlighted as comments or strings are ignored by default, try
`<Enter>*=` on the following lines.
`gaip*=` on the following lines.
```c
@@ -214,14 +226,17 @@ This only works when syntax highlighting is enabled.
Aligning in-line comments
-------------------------
*Note: Since the current version provides '#'-rule as one of the default rules,
you can ignore this section.*
```ruby
apple = 1 # comment not aligned
banana = 'Gros Michel' # comment 2
```
So, how do we align the trailing comments in the above lines?
Simply try `<Enter>-<space>`. The spaces in the comments are ignored, so the
trailing comment in each line is considered to be a single chunk.
So, how do we align the trailing comments in the above lines? Simply try
`-<space>`. The spaces in the comments are ignored, so the trailing comment in
each line is considered to be a single chunk.
But that doesn't work in the following case.
@@ -240,13 +255,13 @@ 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': '#', 'ignore_groups': ['String'] }
```
Notice that the rule overrides `ignores` attribute in order *not to ignore*
Notice that the rule overrides `ignore_groups` attribute in order *not to ignore*
delimiters highlighted as comments.
Then on `<Enter>#`, we get
Then on `#`, we get
```ruby
apple = 1 # comment not aligned
@@ -259,13 +274,16 @@ command:
```vim
" Using regular expression /#/
" - "is" is fuzzy-matched to "*i*gnore*s*"
:EasyAlign/#/{'is':['String']}
" - "ig" is a shorthand notation of "ignore_groups"
:EasyAlign/#/{'ig':['String']}
" Or more concisely with the shorthand notation;
:EasyAlign/#/ig['String']
```
In this case, the second line is ignored as it doesn't contain a `#`. (The one
highlighted as String is ignored.) If you don't want the second line to be
ignored, there are three options:
In this case, the second line is ignored as it doesn't contain a `#` (The one
in `'F#AD'` is ignored as it's highlighted as String). If you don't want the
second line to be ignored, there are three options:
1. Set global `g:easy_align_ignore_unmatched` flag to 0
2. Use `:EasyAlign` command with `ignore_unmatched` option
@@ -277,15 +295,17 @@ let g:easy_align_ignore_unmatched = 0
" 2. Using :EasyAlign command with ignore_unmatched option
" 2-1. Using predefined rule with delimiter key #
" - "iu" is fuzzy-matched to "*i*gnore_*u*nmatched"
" - "iu" is expanded to "*i*gnore_*u*nmatched"
:EasyAlign#{'iu':0}
" or
:EasyAlign#iu0
" 2-2. Using regular expression /#/
:EasyAlign/#/{'is':['String'],'iu':0}
:EasyAlign/#/ig['String']iu0
" 3. Update the alignment rule with ignore_unmatched option
let g:easy_align_delimiters['#'] = {
\ 'pattern': '#', 'ignores': ['String'], 'ignore_unmatched': 0 }
\ 'pattern': '#', 'ignore_groups': ['String'], 'ignore_unmatched': 0 }
```
Then we get,
@@ -308,7 +328,7 @@ static double pi = 3.14;
```
We can align these lines with the predefined `=` rule. Select the lines and
press `<Enter>=`
press `ga=`
```c
const char* str = "Hello";
@@ -318,7 +338,7 @@ static double pi = 3.14;
Not bad. However, the names of the variables, `str`, `count`, and `pi` are not
aligned with each other. Can we do better? We can clearly see that simple
`<Enter><space>` won't properly align those names.
`<space>`-rule won't properly align those names.
So let's define an alignment rule than can handle this case.
```vim
@@ -329,7 +349,7 @@ let g:easy_align_delimiters['d'] = {
```
This new rule aligns text around spaces that are *not* preceded by
`const` or `static`. Let's try it with `<Enter>d`.
`const` or `static`. Let's select the lines and try `gad`.
```c
const char* str = "Hello";
@@ -338,7 +358,7 @@ static double pi = 3.14;
```
Okay, the names are now aligned. We select the lines again with `gv`, and then
press `<Enter>=` to finish our alignment.
press `ga=` to finish our alignment.
```c
const char* str = "Hello";
@@ -369,14 +389,14 @@ So what do we do? Let's try to improve our alignment rule.
```vim
let g:easy_align_delimiters['d'] = {
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
\ 'pattern': ' \ze\S\+\s*[;=]',
\ 'left_margin': 0, 'right_margin': 0
\ }
```
Now the new rule has changed to align text around spaces that are followed
by some non-whitespace characters and then an equals sign or a semi-colon.
Try `<Enter>d`
Try `vipgad`
```c
const char* str = "Hello";
@@ -385,7 +405,7 @@ static double pi = 3.14;
static std::map<std::string, float>* scores = pointer;
```
We're right on track, now press `gv<Enter>=` and voila!
We're right on track, now press `gvga=` and voila!
```c
const char* str = "Hello";

608
README.md
View File

@@ -1,73 +1,148 @@
vim-easy-align
vim-easy-align ![travis-ci](https://travis-ci.org/junegunn/vim-easy-align.svg?branch=master)
==============
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
--------
- Makes the common case easy
- Comes with a predefined set of alignment rules
- Provides a fast and intuitive interface
- Extensible
- You can define your own rules
- Supports arbitrary regular expressions
- Optimized for code editing
- Takes advantage of syntax highlighting feature to avoid unwanted alignments
![](https://raw.githubusercontent.com/junegunn/i/master/easy-align/equals.gif)
Installation
------------
Either [download zip file](http://www.vim.org/scripts/script.php?script_id=4520)
and extract in ~/.vim or use [Vundle](https://github.com/gmarik/vundle) (recommended)
or [Pathogen](https://github.com/tpope/vim-pathogen).
Use your favorite plugin manager.
### With Vundle
Add the following line to your .vimrc,
Using [vim-plug](https://github.com/junegunn/vim-plug):
```vim
Bundle 'junegunn/vim-easy-align'
Plug 'junegunn/vim-easy-align'
```
then execute `:BundleInstall` command.
Quick start guide
-----------------
Add the following mappings to your .vimrc.
```vim
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
```
Then with the following lines of text,
```
apple =red
grass+=green
sky-= blue
```
try these commands:
- `vipga=`
- `v`isual-select `i`nner `p`aragraph
- Start EasyAlign command (`ga`)
- Align around `=`
- `gaip=`
- Start EasyAlign command (`ga`) for `i`nner `p`aragraph
- Align around `=`
Demo
----
*Click on each image to see from the beginning.*
### Using predefined alignment rules
An *alignment rule* is a predefined set of options for common alignment tasks,
which is identified by a single character, such as `<Space>`, `=`, `:`, `.`,
`|`, `&`, `#`, and `,`.
#### `=`
![](https://raw.githubusercontent.com/junegunn/i/master/easy-align/equals.gif)
- `=` Around the 1st occurrences
- `2=` Around the 2nd occurrences
- `*=` Around all occurrences
- `**=` Left/Right alternating alignment around all occurrences
- `<Enter>` Switching between left/right/center alignment modes
#### `<Space>`
![](https://raw.githubusercontent.com/junegunn/i/master/easy-align/spaces.gif)
- `<Space>` Around the 1st occurrences of whitespaces
- `2<Space>` Around the 2nd occurrences
- `-<Space>` Around the last occurrences
- `<Enter><Enter>2<Space>` Center-alignment around the 2nd occurrences
#### `,`
![](https://raw.githubusercontent.com/junegunn/i/master/easy-align/commas.gif)
- The predefined comma-rule places a comma right next to the preceding token
without margin (`{'stick_to_left': 1, 'left_margin': 0}`)
- You can change it with `<Right>` arrow
### Using regular expression
![](https://raw.githubusercontent.com/junegunn/i/master/easy-align/regex.gif)
You can use an arbitrary regular expression by
- pressing `<Ctrl-X>` in interactive mode
- or using `:EasyAlign /REGEX/` command in visual mode or in normal mode with
a range (e.g. `:%`)
### Different ways to start
![](https://raw.githubusercontent.com/junegunn/i/master/easy-align/modes.gif)
This demo shows how you can start interactive mode with visual selection or use
non-interactive `:EasyAlign` command.
### Aligning table cells
![](https://raw.githubusercontent.com/junegunn/i/master/easy-align/tables.gif)
Check out various alignment options and "live interactive mode".
### Syntax-aware alignment
![](https://raw.githubusercontent.com/junegunn/i/master/easy-align/yaml.gif)
Delimiters in strings and comments are ignored by default.
### Using blockwise-visual mode
![](https://raw.githubusercontent.com/junegunn/i/master/easy-align/blockwise-visual.gif)
You can limit the scope with blockwise-visual mode.
Usage
-----
_vim-easy-align_ defines `:EasyAlign` command (and the right-align
variant `:EasyAlign!`) in the visual mode.
### Flow of execution
| Mode | Command |
| ------------------------- | ------------------------------------------------ |
| Interactive mode | `:EasyAlign[!] [OPTIONS]` |
| Using predefined rules | `:EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS]` |
| Using regular expressions | `:EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS]` |
<img src="https://raw.githubusercontent.com/junegunn/i/master/easy-align/usage.png" width="469">
### Interactive mode
There are two ways to use easy-align.
The command will go into the interactive mode when no argument is given.
For convenience, it is advised that you define a mapping for triggering it in
your `.vimrc`.
#### 1. `<Plug>` mappings (interactive mode)
The recommended method is to use `<Plug>(EasyAlign)` mapping in normal and
visual mode. They are usually mapped to `ga`, but you can choose any key
sequences.
```vim
vnoremap <silent> <Enter> :EasyAlign<cr>
nmap ga <Plug>(EasyAlign)
xmap ga <Plug>(EasyAlign)
```
(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 select alignment mode (left, right, or center)
1. Optional field number (default: 1)
1. `ga` key in visual mode, or `ga` followed by a motion or a text
object to start interactive mode
1. (Optional) Enter keys to cycle between alignment mode (left, right, or center)
1. (Optional) N-th delimiter (default: 1)
- `1` Around the 1st occurrences of delimiters
- `2` Around the 2nd occurrences of delimiters
- ...
@@ -76,85 +151,161 @@ With the mapping, you can align selected lines of text with only a few keystroke
- `-` Around the last occurrences of delimiters (`-1`)
- `-2` Around the second to last occurrences of delimiters
- ...
1. Delimiter key (a single keystroke; `<space>`, `=`, `:`, `.`, `|`, `,`)
1. Delimiter key (a single keystroke; `<Space>`, `=`, `:`, `.`, `|`, `&`, `#`, `,`) or an arbitrary regular expression followed by `<CTRL-X>`
Alignment rules for the following delimiters have been defined to meet the most needs.
#### 2. Using `:EasyAlign` command
| Delimiter key | Description/Use cases |
| ------------- | -------------------------------------------------------------------- |
| `<space>` | General alignment around whitespaces |
| `=` | Operators containing equals sign (`=`, `==,` `!=`, `+=`, `&&=`, ...) |
| `:` | Suitable for formatting JSON or YAML |
| `.` | Multi-line method chaining |
| `,` | Multi-line method arguments |
| &#124; | Table markdown |
If you prefer command-line, use `:EasyAlign` command instead.
You can override these default rules or define your own rules with
`g:easy_align_delimiters`, which will be described in the later section.
```vim
" Using predefined rules
:EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]
#### Example command sequences
" Using regular expression
:EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]
```
| With visual map | Description | Equivalent command |
| ------------------- | -------------------------------------------------------- | --------------------- |
| `<Enter><space>` | Alignment around 1st whitespaces | `:'<,'>EasyAlign\ ` |
| `<Enter>2<space>` | Alignment around 2nd whitespaces | `:'<,'>EasyAlign2\ ` |
| `<Enter>-<space>` | Alignment around the last whitespaces | `:'<,'>EasyAlign-\ ` |
| `<Enter>:` | Alignment around 1st colon | `:'<,'>EasyAlign:` |
| `<Enter>=` | Alignment around 1st equals signs (and the likes) | `:'<,'>EasyAlign=` |
| `<Enter>2=` | Alignment around 2nd equals signs (and the likes) | `:'<,'>EasyAlign2=` |
| `<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 alignment around 1st equals signs | `:'<,'>EasyAlign!=` |
| `<Enter><Enter>**=` | Right-left alternating alignment around all equals signs | `:'<,'>EasyAlign!**=` |
| ... | ... | |
### Regular expression vs. predefined rules
### Non-interactive mode
You can use regular expressions but it's usually much easier to use predefined
alignment rules that you can trigger with a single keystroke.
Instead of going into the interactive mode, you can type in arguments to
`:EasyAlign` command. In non-interactive mode, you can even use arbitrary
regular expressions.
| Key | Description/Use cases |
| --------- | -------------------------------------------------------------------- |
| `<Space>` | General alignment around whitespaces |
| `=` | Operators containing equals sign (`=`, `==,` `!=`, `+=`, `&&=`, ...) |
| `:` | Suitable for formatting JSON or YAML |
| `.` | Multi-line method chaining |
| `,` | Multi-line method arguments |
| `&` | LaTeX tables (matches `&` and `\\`) |
| `#` | Ruby/Python comments |
| `"` | Vim comments |
| `<Bar>` | Table markdown |
You can also define your own rules with `g:easy_align_delimiters` which will
be described in [the later section](#extending-alignment-rules).
----
### Interactive mode
Interactive mode is started either with `<Plug>(EasyAlign)` mapping or with
`:EasyAlign` command with no argument.
#### Examples using predefined rules
| Keystrokes | Description | Equivalent command |
| ------------ | ---------------------------------- | --------------------- |
| `<Space>` | Around 1st whitespaces | `:'<,'>EasyAlign\ ` |
| `2<Space>` | Around 2nd whitespaces | `:'<,'>EasyAlign2\ ` |
| `-<Space>` | Around the last whitespaces | `:'<,'>EasyAlign-\ ` |
| `-2<Space>` | Around the 2nd to last whitespaces | `:'<,'>EasyAlign-2\ ` |
| `:` | Around 1st colon (`key: value`) | `:'<,'>EasyAlign:` |
| `<Right>:` | Around 1st colon (`key : value`) | `:'<,'>EasyAlign:>l1` |
| `=` | Around 1st operators with = | `:'<,'>EasyAlign=` |
| `3=` | Around 3rd operators with = | `:'<,'>EasyAlign3=` |
| `*=` | Around all operators with = | `:'<,'>EasyAlign*=` |
| `**=` | Left-right alternating around = | `:'<,'>EasyAlign**=` |
| `<Enter>=` | Right alignment around 1st = | `:'<,'>EasyAlign!=` |
| `<Enter>**=` | Right-left alternating around = | `:'<,'>EasyAlign!**=` |
Instead of finishing the alignment with a delimiter key, you can type in
a regular expression if you press `<CTRL-/>` or `<CTRL-X>`.
#### Alignment options in interactive mode
While in interactive mode, you can set alignment options using special shortcut
keys listed below. The meaning of each option will be described in
[the following sections](#alignment-options).
| Key | Option | Values |
| --------- | ------------------ | -------------------------------------------------- |
| `CTRL-F` | `filter` | Input string (`[gv]/.*/?`) |
| `CTRL-I` | `indentation` | shallow, deep, none, keep |
| `CTRL-L` | `left_margin` | Input number or string |
| `CTRL-R` | `right_margin` | Input number or string |
| `CTRL-D` | `delimiter_align` | left, center, right |
| `CTRL-U` | `ignore_unmatched` | 0, 1 |
| `CTRL-G` | `ignore_groups` | `[]`, `['String']`, `['Comment']`, `['String', 'Comment']` |
| `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 }` |
#### Live interactive mode
If you're performing a complex alignment where multiple options should be
carefully adjusted, try "live interactive mode" where you can preview the result
of the alignment on-the-fly as you type in.
Live interactive mode can be started with either `<Plug>(LiveEasyAlign)` map
or `:LiveEasyAlign` command. Or you can switch to live interactive mode while
in ordinary interactive mode by pressing `<CTRL-P>`. (P for Preview)
In live interactive mode, you have to type in the same delimiter (or
`<CTRL-X>` on regular expression) again to finalize the alignment. This allows
you to preview the result of the alignment and freely change the delimiter
using backspace key without leaving the interactive mode.
### :EasyAlign command
Instead of starting interactive mode, you can use non-interactive `:EasyAlign`
command.
```vim
" Using predefined alignment rules
:EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS]
" :EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]
:EasyAlign :
:EasyAlign =
:EasyAlign *=
:EasyAlign 3\
" Using arbitrary regular expressions
:EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS]
" :EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]
:EasyAlign /[:;]\+/
:EasyAlign 2/[:;]\+/
:EasyAlign */[:;]\+/
:EasyAlign **/[:;]\+/
```
For example, when aligning the following lines around colons and semi-colons,
A command can end with alignment options, [each of which will be discussed in
detail later](#alignment-options), in Vim dictionary format.
apple;:banana::cake
data;;exchange:;format
- `:EasyAlign * /[:;]\+/ { 'stick_to_left': 1, 'left_margin': 0 }`
try these commands:
- `:EasyAlign /[:;]\+/`
- `:EasyAlign 2/[:;]\+/`
- `:EasyAlign */[:;]\+/`
- `:EasyAlign **/[:;]\+/`
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.
- `:EasyAlign * /[:;]\+/ { 'stick_to_left': 1, 'left_margin': '' }`
Then we get:
`stick_to_left` of 1 means that the matched delimiter should be positioned right
next to the preceding token, and `left_margin` of 0 removes the margin on the
left. So we get:
apple;: banana:: cake
data;; exchange:; format
Option names are fuzzy-matched, so you can write as follows:
You don't have to write complete names as long as they're distinguishable.
- `:EasyAlign * /[:;]\+/ { 'stl': 1, 'l': 0 }`
You can even omit spaces between the arguments, so concisely (or cryptically):
You can even omit spaces between the arguments.
- `:EasyAlign*/[:;]\+/{'s':1,'l':0}`
Available options will be shown later in the document.
Nice. But let's make it even shorter. Option values can be written in shorthand
notation.
- `: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` | `<` or `>` |
| `ignore_unmatched` | `iu[01]` |
| `ignore_groups` | `ig\[.*\]` |
| `align` | `a[lrc*]*` |
| `delimiter_align` | `d[lrc]` |
| `indentation` | `i[ksdn]` |
### Partial alignment in blockwise-visual mode
@@ -181,40 +332,70 @@ my_hash = { :a => 1,
```
However, in this case, we don't really need blockwise visual mode
since the same can be easily done using the negative field number: `<Enter>-=`
since the same can be easily done using the negative N-th parameter: `<Enter>-=`
Alignment options
-----------------
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
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` | 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 |
| Option | Type | Default | Description |
| ------------------ | ------- | --------------------- | ------------------------------------------------------- |
| `filter` | string | | Line filtering expression: `g/../` or `v/../` |
| `left_margin` | number | 1 | Number of spaces to attach before delimiter |
| `left_margin` | string | `' '` | String to attach before delimiter |
| `right_margin` | number | 1 | 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_groups` | list | ['String', 'Comment'] | Delimiters in these syntax highlight groups are ignored |
| `ignore_unmatched` | boolean | 1 | Whether to ignore lines without matching delimiter |
| `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 |
| `align` | string | `l` | Alignment modes for multiple occurrences of delimiters |
Some of the options can be specified using corresponding global variables.
There are 4 ways to set alignment options (from lowest precedence to highest):
| Option | Global variable |
| ------------------ | ------------------------------- |
| `ignore_unmatched` | `g:easy_align_ignore_unmatched` |
| `ignores` | `g:easy_align_ignores` |
| `delimiter_align` | `g:easy_align_delimiter_align` |
| `indentation` | `g:easy_align_indentation` |
1. Some option values can be set with corresponding global variables
2. Option values can be specified in the definition of each alignment rule
3. Option values can be given as arguments to `:EasyAlign` command
4. Option values can be set in interactive mode using special shortcut keys
| Option name | Shortcut key | Abbreviated | Global variable |
| ------------------ | ------------------- | -------------- | ------------------------------- |
| `filter` | `CTRL-F` | `[gv]/.*/` | |
| `left_margin` | `CTRL-L` | `l[0-9]+` | |
| `right_margin` | `CTRL-R` | `r[0-9]+` | |
| `stick_to_left` | `<Left>`, `<Right>` | `<` or `>` | |
| `ignore_groups` | `CTRL-G` | `ig\[.*\]` | `g:easy_align_ignore_groups` |
| `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` |
| `align` | `CTRL-A` | `a[lrc*]*` | |
### Filtering lines
With `filter` option, you can align lines that only match or do not match a
given pattern. There are several ways to set the pattern.
1. Press `CTRL-F` in interactive mode and type in `g/pat/` or `v/pat/`
2. In command-line, it can be written in dictionary format: `{'filter': 'g/pat/'}`
3. Or in shorthand notation: `g/pat/` or `v/pat/`
(You don't need to escape '/'s in the regular expression)
#### Examples
```vim
" Start interactive mode with filter option set to g/hello/
EasyAlign g/hello/
" Start live interactive mode with filter option set to v/goodbye/
LiveEasyAlign v/goodbye/
" Align the lines with 'hi' around the first colons
EasyAlign:g/hi/
```
### Ignoring delimiters in comments or strings
@@ -225,8 +406,8 @@ highlighted as code comments or strings are ignored.
```vim
" Default:
" If a delimiter is in a highlight group whose name matches
" any of the followings, it will be ignored.
let g:easy_align_ignores = ['Comment', 'String']
" any of the following regular expressions, it will be ignored.
let g:easy_align_ignore_groups = ['Comment', 'String']
```
For example, the following paragraph
@@ -257,13 +438,15 @@ becomes as follows on `<Enter>:` (or `:EasyAlign:`)
Naturally, this feature only works when syntax highlighting is enabled.
You can change the default rule by using one of these 3 methods.
You can change the default rule by using one of these 4 methods.
1. Define global `g:easy_align_ignores` list
2. Define a custom alignment rule in `g:easy_align_delimiters` with `ignores` option
3. Provide `ignores` option to `:EasyAlign` command. e.g. `:EasyAlign:{'is':[]}`
1. Press `CTRL-G` in interactive mode to switch groups
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:ig[]`
For example if you set `ignores` option to be an empty list, you get
For example if you set `ignore_groups` option to be an empty list, you get
```ruby
{
@@ -276,14 +459,37 @@ For example if you set `ignores` option to be an empty list, you get
}
```
Satisfied? :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.
To make `ignore_groups` work, and to debug the related issues, it is useful to
know which highlight group a certain location in a file belongs to. A special
function exists for this purpose, returning exactly the name of the highlight
group that is used by the easy align plugin.
```vim
" Highlight group name of the cursor position
echo easy_align#get_highlight_group_name()
" Highlight group name of the line 10, column 20
echo easy_align#get_highlight_group_name(10, 20)
```
### Ignoring unmatched lines
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,
```ruby
{
@@ -307,12 +513,13 @@ this is usually what we want.
}
```
However, this default behavior is also configurable by using one of these 3
methods.
However, we can override this default behavior by setting `ignore_unmatched`
option to zero using one of the following 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}`
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:iu0`
Then we get,
@@ -346,7 +553,7 @@ banana += apple
cake ||= banana
```
However, with `:EasyAlign={'da':l}`, delimiters are left-aligned.
However, with `:EasyAlign=dl`, delimiters are left-aligned.
```ruby
apple = 1
@@ -354,7 +561,7 @@ banana += apple
cake ||= banana
```
And on `:EasyAlign={'da':c}`, center-aligned.
And on `:EasyAlign=dc`, center-aligned.
```ruby
apple = 1
@@ -362,6 +569,8 @@ banana += apple
cake ||= banana
```
In interactive mode, you can change the option value with `CTRL-D` key.
### Adjusting indentation
By default :EasyAlign command keeps the original indentation of the lines. But
@@ -384,7 +593,7 @@ 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
@@ -392,7 +601,7 @@ 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
@@ -400,7 +609,7 @@ 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,31 +617,11 @@ 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']
```
In interactive mode, you can change the option value with `CTRL-I` key.
### Alignments over multiple occurrences of delimiters
As stated above, "field number" is used to target specific occurrences of
As stated above, "N-th" parameter is used to target specific occurrences of
the delimiter when it appears multiple times in each line.
To recap:
@@ -457,26 +646,38 @@ To recap:
:EasyAlign! **=
```
In addition to these, you can fine-tune alignments over multiple occurrences of
the delimiters with 'mode_sequence' option.
In addition to these, you can fine-tune alignments over multiple occurrences
of the delimiters with 'align' option. (The option can also be set in
interactive mode with the special key `CTRL-A`)
```vim
" 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 = arlc
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
:EasyAlign 2={ 'm': 'rlc' }
:EasyAlign 2=arlc
" (*) Repeating alignments (default: l, r, or c)
" Right, left, center, center, center, center, ...
:EasyAlign *={ 'm': 'rlc' }
:EasyAlign *=arlc
" (**) Alternating alignments (default: lr or rl)
" Right, left, center, right, left, center, ...
:EasyAlign **={ 'm': 'rlc' }
:EasyAlign **=arlc
" Right, left, center, center, center, ... repeating alignment
" over the 3rd to the last occurrences of delimiters
:EasyAlign 3=arlc*
" Right, left, center, right, left, center, ... alternating alignment
" over the 3rd to the last occurrences of delimiters
:EasyAlign 3=arlc**
```
### Extending alignment rules
@@ -484,13 +685,18 @@ the delimiters with 'mode_sequence' option.
Although the default rules should cover the most of the use cases,
you can extend the rules by setting a dictionary named `g:easy_align_delimiters`.
#### Example
You may refer to the definitions of the default alignment rules
[here](https://github.com/junegunn/vim-easy-align/blob/2.9.6/autoload/easy_align.vim#L32-L46).
#### Examples
```vim
let g:easy_align_delimiters = {
\ '>': { 'pattern': '>>\|=>\|>' },
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignores': ['String'] },
\ '#': { 'pattern': '#\+', 'ignores': ['String'], 'delimiter_align': 'l' },
\ '/': {
\ 'pattern': '//\+\|/\*\|\*/',
\ 'delimiter_align': 'l',
\ 'ignore_groups': ['!Comment'] },
\ ']': {
\ 'pattern': '[[\]]',
\ 'left_margin': 0,
@@ -504,19 +710,61 @@ let g:easy_align_delimiters = {
\ 'stick_to_left': 0
\ },
\ 'd': {
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
\ 'left_margin': 0,
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
\ 'left_margin': 0,
\ 'right_margin': 0
\ }
\ }
```
Other options
-------------
### Disabling &foldmethod during alignment
[It is reported](https://github.com/junegunn/vim-easy-align/issues/14) that
`&foldmethod` value of `expr` or `syntax` can significantly slow down the
alignment when editing a large, complex file with many folds. To alleviate this
issue, EasyAlign provides an option to temporarily set `&foldmethod` to `manual`
during the alignment task. In order to enable this feature, set
`g:easy_align_bypass_fold` switch to 1.
```vim
let g:easy_align_bypass_fold = 1
```
### 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']
```
Advanced examples and use cases
-------------------------------
See [EXAMPLES.md](https://github.com/junegunn/vim-easy-align/blob/master/EXAMPLES.md)
for more examples.
Related work
------------
- [DrChip's Alignment Tool for Vim](http://www.drchip.org/astronaut/vim/align.html)
- [Tabular](https://github.com/godlygeek/tabular)
Author
------

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
" Copyright (c) 2013 Junegunn Choi
" Copyright (c) 2014 Junegunn Choi
"
" MIT License
"
@@ -26,4 +26,118 @@ if exists("g:loaded_easy_align_plugin")
endif
let g:loaded_easy_align_plugin = 1
command! -nargs=* -range -bang EasyAlign <line1>,<line2>call easy_align#align('<bang>' == '!', <q-args>)
command! -nargs=* -range -bang EasyAlign <line1>,<line2>call easy_align#align(<bang>0, 0, 'command', <q-args>)
command! -nargs=* -range -bang LiveEasyAlign <line1>,<line2>call easy_align#align(<bang>0, 1, 'command', <q-args>)
let s:last_command = 'EasyAlign'
function! s:abs(v)
return a:v >= 0 ? a:v : - a:v
endfunction
function! s:remember_visual(mode)
let s:last_visual = [a:mode, s:abs(line("'>") - line("'<")), s:abs(col("'>") - col("'<"))]
endfunction
function! s:repeat_visual()
let [mode, ldiff, cdiff] = s:last_visual
let cmd = 'normal! '.mode
if ldiff > 0
let cmd .= ldiff . 'j'
endif
let ve_save = &virtualedit
try
if mode == "\<C-V>"
if cdiff > 0
let cmd .= cdiff . 'l'
endif
set virtualedit+=block
endif
execute cmd.":\<C-r>=g:easy_align_last_command\<Enter>\<Enter>"
call s:set_repeat()
finally
if ve_save != &virtualedit
let &virtualedit = ve_save
endif
endtry
endfunction
function! s:repeat_in_visual()
if exists('g:easy_align_last_command')
call s:remember_visual(visualmode())
call s:repeat_visual()
endif
endfunction
function! s:set_repeat()
silent! call repeat#set("\<Plug>(EasyAlignRepeat)")
endfunction
function! s:generic_easy_align_op(type, vmode, live)
if !&modifiable
if a:vmode
normal! gv
endif
return
endif
let sel_save = &selection
let &selection = "inclusive"
if a:vmode
let vmode = a:type
let [l1, l2] = ["'<", "'>"]
call s:remember_visual(vmode)
else
let vmode = ''
let [l1, l2] = [line("'["), line("']")]
unlet! s:last_visual
endif
try
let range = l1.','.l2
if get(g:, 'easy_align_need_repeat', 0)
execute range . g:easy_align_last_command
else
execute range . "call easy_align#align(0, a:live, vmode, '')"
end
call s:set_repeat()
finally
let &selection = sel_save
endtry
endfunction
function! s:easy_align_op(type, ...)
call s:generic_easy_align_op(a:type, a:0, 0)
endfunction
function! s:live_easy_align_op(type, ...)
call s:generic_easy_align_op(a:type, a:0, 1)
endfunction
function! s:easy_align_repeat()
if exists('s:last_visual')
call s:repeat_visual()
else
try
let g:easy_align_need_repeat = 1
normal! .
finally
unlet! g:easy_align_need_repeat
endtry
endif
endfunction
nnoremap <silent> <Plug>(EasyAlign) :set opfunc=<SID>easy_align_op<Enter>g@
vnoremap <silent> <Plug>(EasyAlign) :<C-U>call <SID>easy_align_op(visualmode(), 1)<Enter>
nnoremap <silent> <Plug>(LiveEasyAlign) :set opfunc=<SID>live_easy_align_op<Enter>g@
vnoremap <silent> <Plug>(LiveEasyAlign) :<C-U>call <SID>live_easy_align_op(visualmode(), 1)<Enter>
" vim-repeat support
nnoremap <silent> <Plug>(EasyAlignRepeat) :call <SID>easy_align_repeat()<Enter>
vnoremap <silent> <Plug>(EasyAlignRepeat) :<C-U>call <SID>repeat_in_visual()<Enter>
" Backward-compatibility (deprecated)
nnoremap <silent> <Plug>(EasyAlignOperator) :set opfunc=<SID>easy_align_op<Enter>g@
" vim: set et sw=2 :

13
test/README.md Normal file
View File

@@ -0,0 +1,13 @@
Test cases for vim-easy-align
=============================
### Prerequisite
- [Vader.vim](https://github.com/junegunn/vader.vim)
### Run
```
./run
```

View File

@@ -1,923 +0,0 @@
" :source run.vim
" @a
Pa ul Mc Ca rt ne y{ {1 }} 94 2
Ge or ge Ha rr is on {{ 1} }9 43
Ri ng o St ar r {{ 1} }9 40
Pe te Be st {{ 1} }9 41
Paul McCartney{{1}}942
George Harrison {{1}}943
Ringo Starr {{1}}940
Pete Best {{1}}941
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
Ringo Starr 1940
Pete Best 1941
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
Ringo Starr 1940
Pete Best 1941
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
Ringo Starr 1940
Pete Best 1941
Paul McCartney 1942
George Harrison 1943
Ringo Starr 1940
Pete Best 1941
Paul McCartney 1942
George Harrison 1943
Ringo Starr 1940
Pete Best 1941
| 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 |
aaa, bb, c
d, eeeeeee
fffff, gggggggggg,
h, , ii
j, , k
```ruby
a =
a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
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
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
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
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
options = { :caching => nil,
:versions => 3,
"cache=blocks" => false }.merge(options)
options = { :caching => nil,
:versions => 3,
"cache=blocks" => false }.merge(options)
options = { :caching => nil,
:versions => 3,
"cache=blocks" => false }.merge(options)
apple = 1 # comment not aligned
banana = 'Gros Michel' # comment 2
# let g:easy_align_delimiters = { '#': { 'pattern': '#\+', 'ignores': ['String'] } }
apple = 1 # comment not aligned
apricot = 'DAD' + 'F#AD'
banana = 'Gros Michel' # comment 2
apple = 1 # comment not aligned
apricot = 'DAD' + 'F#AD'
banana = 'Gros Michel' # comment 2
```
```yaml
mysql:
# JDBC driver for MySQL database:
driver: com.mysql.jdbc.Driver
# JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE)
url: jdbc:mysql://localhost/test
database: test
"user:pass": r00t:pa55
mysql:
# JDBC driver for MySQL database:
driver: com.mysql.jdbc.Driver
# JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE)
url: jdbc:mysql://localhost/test
database: test
"user:pass": r00t:pa55
```
```c
/* a */ b = c
aa >= bb
// aaa = bbb = cccc
/* aaaa = */ bbbb === cccc " = dddd = " = eeee
aaaaa /* bbbbb */ == ccccc /* != eeeee = */ === fffff
/* a */ b = c
aa >= bb
// aaa = bbb = cccc
/* aaaa = */ bbbb === cccc " = dddd = " = eeee
aaaaa /* bbbbb */ == ccccc /* != eeeee = */ === fffff
```
my_object
.method1 .chain
.second_method.call
.third .call
.method_4 .execute
my_object
.method1 . chain
.second_method. call
.third . call
.method_4 .execute
my_object
. method1.chain
.second_method.call
. third.call
. method_4.execute
my_object
. method1.chain
.second_method.call
. third.call
. method_4.execute
my_object
. method1. chain
.second_method. call
. third. call
. method_4.execute
my_object
.method1 .chain
.second_method.call
.third .call
.method_4 .execute
my_object
.method1.chain
.second_method.call
.third.call
.method_4.execute
my_object .
method1 .chain.
second_method.call.
third .call.
method_4 .execute
| 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 |
| 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
const char* str = "Hello";
int64_t count = 1 + 2;
static double pi = 3.14;
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
... - . -----
.. -- .. ----
. --- ... ---
---- .... --
. --- ..... -
.. -- ......
... - ..... -
... - . -----
.. -- .. ----
. --- ... ---
---- .... --
. --- ..... -
.. -- ......
... - ..... -
... - . -----
.. -- .. ----
. --- ... ---
---- .... --
. --- ..... -
.. -- ......
... - ..... -
... - . -----
.. -- .. ----
. --- ... ---
---- .... --
. --- ..... -
.. -- ......
... - ..... -
... - .-----
.. -- ..----
. --- ...---
---- ....--
. --- .....-
.. -- ......
... - .....-
... - . -----
.. -- .. ----
. --- ... ---
---- .... --
. --- ..... -
.. -- ......
... - ..... -
... - .-----
.. -- ..----
. --- ...---
---- ....--
. --- .....-
.. -- ......
... - .....-
... - .-----
.. -- ..----
. --- ...---
---- ....--
. --- .....-
.. -- ......
... - .....-
...-.-----
..--..----
.---...---
----....--
.---.....-
..--......
...-.....-
... - . -----
.. -- .. ----
. --- ... ---
---- .... --
. --- ..... -
.. -- ......
... - ..... -
... - .-----
.. -- ..----
. --- ...---
---- ....--
. --- .....-
.. -- ......
... - .....-
... - . -----
.. -- .. ----
. --- ... ---
---- .... --
. --- ..... -
.. -- ......
... - ..... -
... - . -----
.. -- .. ----
. --- ... ---
---- .... --
. --- ..... -
.. -- ......
... - ..... -
...-. -----
..--.. ----
.---... ---
----.... --
.---..... -
..--......
...-..... -
... - .-----
.. -- ..----
. --- ...---
---- ....--
. --- .....-
.. -- ......
... - .....-
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

@@ -1,219 +0,0 @@
" :source run.vim
" @a
Paul McCartney 1942
George Harrison 1943
Ringo Starr 1940
Pete Best 1941
| 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 |
aaa, bb,c
d,eeeeeee
fffff, gggggggggg,
h, , ii
j,,k
```ruby
a =
a = 1
bbbb = 2
ccccccc = 3
ccccccccccccccc
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
options = { :caching => nil,
:versions => 3,
"cache=blocks" => false }.merge(options)
apple = 1 # comment not aligned
banana = 'Gros Michel' # comment 2
# let g:easy_align_delimiters = { '#': { 'pattern': '#\+', 'ignores': ['String'] } }
apple = 1 # comment not aligned
apricot = 'DAD' + 'F#AD'
banana = 'Gros Michel' # comment 2
```
```yaml
mysql:
# JDBC driver for MySQL database:
driver: com.mysql.jdbc.Driver
# JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE)
url: jdbc:mysql://localhost/test
database: test
"user:pass":r00t:pa55
```
```c
/* a */ b = c
aa >= bb
// aaa = bbb = cccc
/* aaaa = */ bbbb === cccc " = dddd = " = eeee
aaaaa /* bbbbb */ == ccccc /* != eeeee = */ === fffff
```
my_object
.method1.chain
.second_method.call
.third.call
.method_4.execute
my_object.
method1.chain.
second_method.call.
third.call.
method_4.execute
| 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
const char* str = "Hello";
int64_t count = 1 + 2;
static double pi = 3.14;
static std::map<std::string, float>* scores = pointer;
```
Paul McCartney 1942
George Harrison 1943
Ringo Starr 1940
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 +0,0 @@
4Gvipjyvip

22
test/blockwise.vader Normal file
View File

@@ -0,0 +1,22 @@
Include: include/setup.vader
Given clojure:
(def world [[1 1 1 1 1]
[999 999 999 999 1]
[1 1 1 1 1]
[1 999 999 999 999]
[1 1 1 1 1]])
Do (Recursive alignment in blockwise-visual mode):
f[;
\<C-V>G
\<Enter>*\<Space>
Expect clojure:
(def world [[1 1 1 1 1]
[999 999 999 999 1]
[1 1 1 1 1]
[1 999 999 999 999]
[1 1 1 1 1]])
Include: include/teardown.vader

191
test/commandline.vader Normal file
View File

@@ -0,0 +1,191 @@
Include: include/setup.vader
Given (fruits):
apple;:;;banana::cake
data;;exchange:;::format
Execute (regular expression):
%EasyAlign/[:;]\+/
AssertEqual ':EasyAlign /[:;]\+/', g:easy_align_last_command
Expect:
apple ;:;; banana::cake
data ;; exchange:;::format
Execute (options dictionary):
%EasyAlign/[:;]\+/{ 'left_margin': '<', 'right_margin': 3 }
Expect:
apple<;:;; banana::cake
data < ;; exchange:;::format
Execute (fuzzy matching):
%EasyAlign/[:;]\+/{ 'l':'<', 'r': '>'}
Expect:
apple<;:;;>banana::cake
data < ;;>exchange:;::format
Execute (shorthand notation of margin):
%EasyAlign/[:;]\+/l0r0
Expect:
apple;:;;banana::cake
data ;;exchange:;::format
Execute (delimiter align):
%EasyAlign*/[:;]\+/l0r0dc
Expect:
apple;:;;banana :: cake
data ;; exchange:;::format
Execute (DEPRECATED: shorthand notation of mode_sequence and margin):
%EasyAlign/[:;]\+/mrc*l2r2
Expect:
apple ;:;; banana :: cake
data ;; exchange :;:: format
Execute (shorthand notation of align and margin):
%EasyAlign/[:;]\+/arc*l2r2
Expect:
apple ;:;; banana :: cake
data ;; exchange :;:: format
Execute (DEPRECATED: deep indentation):
%EasyAlign/[:;]\+/mrc*l2r2
%EasyAlign*/[:;]\+/idmrl*
Expect:
apple ;:;; banana :: cake
data ;; exchange :;:: format
Execute (deep indentation):
%EasyAlign/[:;]\+/arc*l2r2
%EasyAlign*/[:;]\+/idarl*
Expect:
apple ;:;; banana :: cake
data ;; exchange :;:: format
Execute (stick_to_left):
%EasyAlign*/[:;]\+/stl1l0dlrm3
Expect:
apple;:;; banana:: cake
data;; exchange:;:: format
Execute (<):
%EasyAlign*/[:;]\+/<l0dlrm3
Expect:
apple;:;; banana:: cake
data;; exchange:;:: format
Execute (>):
%EasyAlign*/[:;]\+/l0dl<>rm3
Expect:
apple;:;; banana :: cake
data ;; exchange:;:: format
Execute (different regular expression):
%EasyAlign*/../{'lm':'<','rm':'>'}
Expect:
ap><pl><e;><:;><;b><an><an><a:><:c><ak>e
da><ta><;;><ex><ch><an><ge><:;><::><fo><rm><at
Execute (merge different option notations):
%EasyAlign*/../iu0 { 'l': '<', 'r': '>' }
Expect:
ap><pl><e;><:;><;b><an><an><a:><:c><ak>e
da><ta><;;><ex><ch><an><ge><:;><::><fo> <rm><at
Execute (Use current search pattern as delimiter if empty regular expression is given):
/an
%EasyAlign*//
Expect:
apple;:;;b an an a::cake
data;;exch an ge:;::format
Given javascript (json):
var jdbc = {
// JDBC driver for MySQL database:
driver: "com.mysql.jdbc.Driver",
/* JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE) */
url: 'jdbc:mysql://localhost/test',
database: "test",
"user:pass":"r00t:pa55"
};
Execute (default syntax-aware alignment):
%EasyAlign*:
Expect javascript:
var jdbc = {
// JDBC driver for MySQL database:
driver: "com.mysql.jdbc.Driver",
/* JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE) */
url: 'jdbc:mysql://localhost/test',
database: "test",
"user:pass": "r00t:pa55"
};
Execute (do not ignore unmatched):
%EasyAlign*:iu0
Expect javascript:
var jdbc = {
// JDBC driver for MySQL database:
driver: "com.mysql.jdbc.Driver",
/* JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE) */
url: 'jdbc:mysql://localhost/test',
database: "test",
"user:pass": "r00t:pa55"
};
Execute (do not ignore any group):
%EasyAlign*:ig[]iu0
Expect javascript:
var jdbc = {
// JDBC driver for MySQL database:
driver: "com.mysql.jdbc.Driver",
/* JDBC URL for the connection (jdbc: mysql: //HOSTNAME/DATABASE) */
url: 'jdbc: mysql: //localhost/test',
database: "test",
"user: pass": "r00t: pa55"
};
Execute (ignore only strings):
%EasyAlign*:ig['String']
Expect javascript:
var jdbc = {
// JDBC driver for MySQL database:
driver: "com.mysql.jdbc.Driver",
/* JDBC URL for the connection (jdbc: mysql: //HOSTNAME/DATABASE) */
url: 'jdbc:mysql://localhost/test',
database: "test",
"user:pass": "r00t:pa55"
};
Execute (ignore only comments):
%EasyAlign*:ig['Comment']
Expect javascript:
var jdbc = {
// JDBC driver for MySQL database:
driver: "com.mysql.jdbc.Driver",
/* JDBC URL for the connection (jdbc:mysql://HOSTNAME/DATABASE) */
url: 'jdbc: mysql: //localhost/test',
database: "test",
"user: pass": "r00t: pa55"
};
Include: include/teardown.vader

13
test/extra.vader Normal file
View File

@@ -0,0 +1,13 @@
Include: include/setup.vader
Before:
set nomodifiable
After:
set modifiable
AssertEqual "hello\nworld\n", @"
Given:
hello
world
Do (#43 Do nothing when nomodifiable):
vip\<enter>\<enter>\<enter>y

263
test/fixed.vader Normal file
View File

@@ -0,0 +1,263 @@
Include: include/setup.vader
Given (Table):
|a|b|c|d|
| -|-|>-|-|
|aaa|bbb|ccc|ddd|
Do (Partial alignment around 1st |):
\<C-V>ljj\<Enter>|
Expect (Right margin should be correctly attached):
| a|b|c|d|
| -|-|>-|-|
| aaa|bbb|ccc|ddd|
Given (empty buffer):
Execute (Aligning lines with many delimiters should not fail):
call visualmode(1)
call setline(1, repeat('|', &maxfuncdepth + 1))
%EasyAlign*|
AssertEqual (&maxfuncdepth + 1) * 3 - 2, len(getline(1))
Given:
a | b | c
aa | bb | cc
Execute:
%EasyAlign*|iu0{'l':'<', 'r': '>'}
Expect:
a <|>b <|>c
aa<|>bb<|>cc
Given (Trailing delimiter):
a | b | c |
aa | bb | cc |
Execute:
%EasyAlign*|iu0{'l':'<', 'r': '>'}
Expect:
a <|>b <|>c <|
aa<|>bb<|>cc<|
Given (Tab-indented code (#20)):
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Execute:
set tabstop=1
%EasyAlign=
Expect:
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Execute:
set tabstop=2
%EasyAlign=
Expect:
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Execute:
set tabstop=4
%EasyAlign=
Expect:
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Execute:
set tabstop=8
%EasyAlign=
Expect:
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Execute:
set tabstop=12
%EasyAlign=
Expect:
class MyUnitTest(unittest.TestCase):
def test_base(self):
n2f = {}
n2v = {}
f2v = {}
n2gv = {}
n2vt = {}
Given (Tab-indented code (#20)):
class MyUnitTest(unittest.TestCase):
def test_base(self):
# n2f= {}
## n2v= {}
# f2v = {}
## n2gv = {}
# n2vt = {}
Execute:
set tabstop=12
%EasyAlign=
Expect:
class MyUnitTest(unittest.TestCase):
def test_base(self):
# n2f = {}
## n2v = {}
# f2v = {}
## n2gv = {}
# n2vt = {}
Given (Some text):
a,b,c
d,e,f
Do (Select 1st line, align 3rd line):
- First line
V\<esc>
- Last line
G
- Align
\<space>Aip*,
- Previous selection
gv
- Upcase
U
Expect:
A,B,C
d, e, f
Given c (#40 Ignored delimiters in LiveEasyAlign causes spurious undo):
printf("foo = %f\n", foo);
printf("foobar = %f\n", foobar);
Do:
gUiw
:%LiveEasyAlign\<enter>
=\<bs>==
Expect c:
PRINTF("foo = %f\n", foo);
printf("foobar = %f\n", foobar);
* #50 Error when using delimiter alignment option
Given:
a|bbb|c
aa|bb|cc
Do (#50 EasyAlign command with 'a' option):
:%EasyAlign {'a': 'l'}\<cr>
\<cr>
*|
Expect (Some text):
a | bbb | c
aa | bb | cc
* #51 Repeat of visual <Plug>(LiveEasyAlign) broken
Do (#51/#52 <Plug>(EasyAlignRepeat) in visual mode):
V\<space>\<enter>\<enter>*||
G
V\<space>.
Expect:
a | bbb | c
aa | bb | cc
* #65 ?=
Given:
a?=b
aa-=bb
aaa?=bbb
Do (#65 Alignment around ?=):
\<space>Aip=
Expect:
a ?= b
aa -= bb
aaa ?= bbb
* #67 \v
Given c:
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(SERV_PORT);
Execute (#67 \v breaks surrounding regex):
%EasyAlign/\v(\=\s)@<=</
Expect:
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(SERV_PORT);
Execute (#67 \V followed by \v shouldn't matter):
%EasyAlign/\v(\=\s)@<=<\V/
Expect:
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(SERV_PORT);
Execute (#67 \zs is now allowed):
%EasyAlign/=\zs/
Expect:
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(SERV_PORT);
Include: include/teardown.vader
Given:
hello = world bye all
hello world = bye all
hello world = foo all
Do (#105: Incorrectly detection of blockwise visual mode):
\<c-v>jj\<esc>
\<Space>Aip=
Expect:
hello = world bye all
hello world = bye all
hello world = foo all

24
test/fixme.vader Normal file
View File

@@ -0,0 +1,24 @@
Include: include/setup.vader
# It is currently possible that EasyAlign command incorrectly judges
# that it was executed in block-wise visual mode
Given:
a|b|c
Do (FIXME invalid judgement - block-wise visual mode):
\<C-V>\<Esc>
:%EasyAlign|\<CR>
Expect:
a | b | c
Do (TODO Workaround: reset visualmode() on error):
\<C-V>\<Esc>
:%EasyAlign|\<CR>
:%EasyAlign|\<CR>
Expect:
a | b | c
Include: include/teardown.vader

View File

@@ -1,45 +0,0 @@
function! GFM()
let syntaxes = {
\ 'ruby': 'syntax/ruby.vim',
\ 'yaml': 'syntax/yaml.vim',
\ 'vim': 'syntax/vim.vim',
\ 'sh': 'syntax/sh.vim',
\ 'python': 'syntax/python.vim',
\ 'java': 'syntax/java.vim',
\ 'c': 'syntax/c.vim'
\ }
for [lang, syn] in items(syntaxes)
unlet b:current_syntax
silent! exec printf("syntax include @%s %s", lang, syn)
exec printf("syntax region %sSnip matchgroup=Snip start='```%s' end='```' contains=@%s",
\ lang, lang, lang)
endfor
let b:current_syntax='mkd'
syntax sync fromstart
endfunction
silent! unlet g:easy_align_delimiters
silent! unlet g:easy_align_ignore_unmatched
silent! unlet g:easy_align_ignores
vnoremap <silent> <Enter> :EasyAlign<cr>
noremap <silent> <C-k> <nop>
noremap <silent> <C-j> <nop>
noremap <silent> <C-h> <nop>
noremap <silent> <C-l> <nop>
vnoremap <silent> <C-k> <nop>
vnoremap <silent> <C-j> <nop>
vnoremap <silent> <C-h> <nop>
vnoremap <silent> <C-l> <nop>
set nolazyredraw
set buftype=nofile
set colorcolumn=
silent! ScrollPositionHide
call GFM()

38
test/include/setup.vader Normal file
View File

@@ -0,0 +1,38 @@
Execute (Clean up test environment):
Save g:easy_align_ignore_groups, g:easy_align_ignore_unmatched
Save g:easy_align_indentation, g:easy_align_delimiter_align
Save g:easy_align_interactive_modes, g:easy_align_bang_interactive_modes
Save g:easy_align_delimiters, g:easy_align_bypass_fold
Save &tabstop, mapleader
unlet! g:easy_align_ignore_groups
unlet! g:easy_align_ignore_unmatched
unlet! g:easy_align_indentation
unlet! g:easy_align_delimiter_align
unlet! g:easy_align_interactive_modes
unlet! g:easy_align_bang_interactive_modes
unlet! g:easy_align_bypass_fold
let g:easy_align_delimiters = {}
let mapleader = ' '
vnoremap <silent> r<Enter> :EasyAlign!<Enter>
vnoremap <silent> <Leader>r<Enter> :LiveEasyAlign!<Enter>
" " Legacy
" vnoremap <silent> <Enter> :EasyAlign<Enter>
" vnoremap <silent> <Leader><Enter> :LiveEasyAlign<Enter>
" nmap <leader>A <Plug>(EasyAlignOperator)
set ts=2
vmap <Enter> <Plug>(EasyAlign)
vmap <leader><Enter> <Plug>(LiveEasyAlign)
nmap <leader>A <Plug>(EasyAlign)
vmap <leader>. <Plug>(EasyAlignRepeat)
silent! call plug#load('vim-easy-align')
Before:
After:
Given:

View File

@@ -0,0 +1,4 @@
Given:
Execute (Restoring test environment):
Restore

1886
test/interactive.vader Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,96 +0,0 @@
" :source run.vim
" @a
apple;:banana :: cake
data;;exchange :; format
apple ;: banana :: cake
data ;; exchange :; format
apple ;: banana :: cake
data ;; exchange :; format
apple ;:____banana::cake
data ;;____exchange:;format
apple ; : banana : : cake
data ; ; exchange : ; format
ap pl e; :b an an a: :c ak e
da ta ;; ex ch an ge :; fo rm at
ap ple;:banana::cake
da ta;;exchange:;format
apple???;:~~~banana???::~~~ cake
data???;;~~~ exchange???:;~~~format
apple;: banana::cake
data;; exchange:;format
apple<<<;:>>>banana::cake
data <<<;;>>>exchange:;format
apple ;: banana::cake
data ;; exchange:;format
apple;:banana :: cake
data;;exchange :; format
apple ;: banana :: cake
data ;; exchange :; format
apple ;: banana :: cake
data ;; exchange :; format
apple ;: banana :: cake
data ;; exchange :; format
apple ;: banana :: cake
data ;; exchange :; format
apple ;: banana::cake
data ;; exchange:;format
apple ; :banana::cake
data ; ; exchange: ; format
apple ; :banana::cake
data ; ;exchange:;format
apple ; :banana::cake
data ; ;exchange:;format
apple;:banana::cake
data;;exchange:;format
apple;: banana: : cake
data;;exchange: ;format
apple;:banana: :cake
data;;exchange:;format
apple;:banana: :cake
data;;exchange:;format
apple;: banana: : cake
data;;exchange: ;format
apple;:banana:: cake
data;;exchange: ;format
apple;: banana: : cake
data;;exchange: ;format
apple;: banana::cake
data;;exchange: ;format
```ruby
apple = 1 # comment not aligned
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(

View File

@@ -1,12 +0,0 @@
" :source run.vim
" @a
apple;:banana::cake
data;;exchange:;format
```ruby
apple = 1 # comment not aligned
apricot = 'DAD' + 'F#AD'
banana = 'Gros Michel' # comment 2
```

View File

@@ -1 +0,0 @@
4Gvipjyvip:EasyAlign:

11
test/run Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
cd $(dirname $BASH_SOURCE)
vim -Nu <(cat << EOF
syntax on
for dep in ['vader.vim', 'vim-repeat']
execute 'set rtp+=' . finddir(dep, expand('~/.vim').'/**')
endfor
set rtp+=..
EOF) +Vader*

View File

@@ -1,7 +0,0 @@
e!
execute 'source '. expand('%:p:h') . '/include.vim'
normal gg
let @b=system('cat '. expand('%:p:r') . '.script')
let @a='@b:vert diffsplit ' . expand('%:p:r') . '.expected
'

158
test/tex.vader Normal file
View File

@@ -0,0 +1,158 @@
# http://en.wikibooks.org/wiki/LaTeX/Tables
Include: include/setup.vader
Given tex (table with escaped &):
\begin{tabular}{ l c r }
1&2&3\\
44&55&66\\
777&8\&8&999\\
\end{tabular}
# FIXME vip doesn't work if folded
Do (Align around all &s and \\s):
VG\<Enter>*&
Expect tex:
\begin{tabular}{ l c r }
1 & 2 & 3 \\
44 & 55 & 66 \\
777 & 8\&8 & 999 \\
\end{tabular}
Do (right-align with explicit ignore_unmatched):
VG\<Enter>\<Enter>\<C-U>\<C-U>*&
Expect tex:
\begin{tabular}{ l c r }
1 & 2 & 3 \\
44 & 55 & 66 \\
777 & 8\&8 & 999 \\
\end{tabular}
Do (center-align with explicit ignore_unmatched):
VG\<Enter>\<Enter>\<Enter>\<C-U>\<C-U>*&
Expect tex:
\begin{tabular}{ l c r }
1 & 2 & 3 \\
44 & 55 & 66 \\
777 & 8\&8 & 999 \\
\end{tabular}
Given tex (simple table with \hline):
\begin{tabular}{ l c r }
1&2&3\\ \hline
44&55&66\\ \hline
777&8\&&999\\ \hline
\end{tabular}
Do:
VG\<Enter>*&
Expect tex:
\begin{tabular}{ l c r }
1 & 2 & 3 \\ \hline
44 & 55 & 66 \\ \hline
777 & 8\& & 999 \\ \hline
\end{tabular}
Given tex (table with lines w/o &s):
\begin{tabular}{|r|l|}
\hline
7C0 & hexadecimal \\
3700&octal \\ \cline{2-2}
1111100000 & binary \\
\hline \hline
1984 & decimal \\
\hline
\end{tabular}
Do (left-align*):
VG\<Enter>*&
Expect tex:
\begin{tabular}{|r|l|}
\hline
7C0 & hexadecimal \\
3700 & octal \\ \cline{2-2}
1111100000 & binary \\
\hline \hline
1984 & decimal \\
\hline
\end{tabular}
Do(left-align* and right-align around 2nd):
VG\<Enter>*&
gv\<Enter>\<Enter>2&
Expect tex:
\begin{tabular}{|r|l|}
\hline
7C0 & hexadecimal \\
3700 & octal \\ \cline{2-2}
1111100000 & binary \\
\hline \hline
1984 & decimal \\
\hline
\end{tabular}
Given tex:
\begin{tabular}{}
32&1.14\e1&&5.65\e2&&&&1.16\e1&&1.28\e1&\\
64&1.03\e1&0.1&4.98\e2&0.2&&&9.21\e2&0.3&1.02\e1&0.3\\
128&9.86\e2&0.1&4.69\e2&0.1&&&8.46\e2&0.1&9.45\e2&0.1\\
256&9.65\e2&0.0&4.59\e2&0.0&&&8.15\e2&0.1&9.11\e2&0.1\\
% 512&9.55\e2&0.0&4.56\e2&0.0&&&8.01\e2&0.0&8.96\e2&0.0\\
1024&9.49\e2&0.0&4.53\e2&0.0&&&7.94\e2&0.0&8.89\e2&0.0\\
2048&9.47\e2&0.0&4.52\e2&0.0&&&7.91\e2&0.0&8.85\e2&0.0\\
4096&9.46\e2&0.0&4.51\e2&0.0%&&&7.90\e2&0.0&8.83\e2&0.0\\
8192&9.45\e2&0.0&4.51\e2&0.0&&&&&&\\
\end{tabular}
Execute (Alignment around &s, foldmethod should not change):
setlocal foldmethod=syntax
%EasyAlign*&
AssertEqual 'syntax', &l:foldmethod
setlocal foldmethod=manual
%EasyAlign*&
AssertEqual 'manual', &l:foldmethod
Expect tex:
\begin{tabular}{}
32 & 1.14\e1 & & 5.65\e2 & & & & 1.16\e1 & & 1.28\e1 & \\
64 & 1.03\e1 & 0.1 & 4.98\e2 & 0.2 & & & 9.21\e2 & 0.3 & 1.02\e1 & 0.3 \\
128 & 9.86\e2 & 0.1 & 4.69\e2 & 0.1 & & & 8.46\e2 & 0.1 & 9.45\e2 & 0.1 \\
256 & 9.65\e2 & 0.0 & 4.59\e2 & 0.0 & & & 8.15\e2 & 0.1 & 9.11\e2 & 0.1 \\
% 512&9.55\e2&0.0&4.56\e2&0.0&&&8.01\e2&0.0&8.96\e2&0.0\\
1024 & 9.49\e2 & 0.0 & 4.53\e2 & 0.0 & & & 7.94\e2 & 0.0 & 8.89\e2 & 0.0 \\
2048 & 9.47\e2 & 0.0 & 4.52\e2 & 0.0 & & & 7.91\e2 & 0.0 & 8.85\e2 & 0.0 \\
4096 & 9.46\e2 & 0.0 & 4.51\e2 & 0.0%&&&7.90\e2&0.0&8.83\e2&0.0\\
8192 & 9.45\e2 & 0.0 & 4.51\e2 & 0.0 & & & & & & \\
\end{tabular}
Execute (g:easy_align_bypass_fold set, foldmethod should not change):
let g:easy_align_bypass_fold = 1
setlocal foldmethod=syntax
%EasyAlign*&
AssertEqual 'syntax', &l:foldmethod
setlocal foldmethod=manual
%EasyAlign*&
AssertEqual 'manual', &l:foldmethod
Expect tex:
\begin{tabular}{}
32 & 1.14\e1 & & 5.65\e2 & & & & 1.16\e1 & & 1.28\e1 & \\
64 & 1.03\e1 & 0.1 & 4.98\e2 & 0.2 & & & 9.21\e2 & 0.3 & 1.02\e1 & 0.3 \\
128 & 9.86\e2 & 0.1 & 4.69\e2 & 0.1 & & & 8.46\e2 & 0.1 & 9.45\e2 & 0.1 \\
256 & 9.65\e2 & 0.0 & 4.59\e2 & 0.0 & & & 8.15\e2 & 0.1 & 9.11\e2 & 0.1 \\
% 512&9.55\e2&0.0&4.56\e2&0.0&&&8.01\e2&0.0&8.96\e2&0.0\\
1024 & 9.49\e2 & 0.0 & 4.53\e2 & 0.0 & & & 7.94\e2 & 0.0 & 8.89\e2 & 0.0 \\
2048 & 9.47\e2 & 0.0 & 4.52\e2 & 0.0 & & & 7.91\e2 & 0.0 & 8.85\e2 & 0.0 \\
4096 & 9.46\e2 & 0.0 & 4.51\e2 & 0.0%&&&7.90\e2&0.0&8.83\e2&0.0\\
8192 & 9.45\e2 & 0.0 & 4.51\e2 & 0.0 & & & & & & \\
\end{tabular}
Include: include/teardown.vader