mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-17 14:23:42 -05:00
Compare commits
92 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2daae46a43 | ||
|
|
2b119f9bb6 | ||
|
|
15bcbc9499 | ||
|
|
54e6b5d866 | ||
|
|
1f28ce346e | ||
|
|
2832a76cea | ||
|
|
1a232ac19b | ||
|
|
a76cfdb8ae | ||
|
|
c3a7842b0d | ||
|
|
3cc564bd68 | ||
|
|
6e2264672a | ||
|
|
bec3e94383 | ||
|
|
7f0fccba0b | ||
|
|
aa62ca4603 | ||
|
|
831cecdaf2 | ||
|
|
37fa908d04 | ||
|
|
256e5b83ab | ||
|
|
cb7306341c | ||
|
|
7b82a1e496 | ||
|
|
ad2df21039 | ||
|
|
4c2808d13c | ||
|
|
124654ec46 | ||
|
|
ab4b72addf | ||
|
|
cdc648f5a4 | ||
|
|
438b5312ee | ||
|
|
e24f8479a5 | ||
|
|
9d626dd765 | ||
|
|
7490aa61d7 | ||
|
|
aa42666f10 | ||
|
|
9951cad2d0 | ||
|
|
cb5041ba67 | ||
|
|
7019edb08c | ||
|
|
247f69bf3f | ||
|
|
133588b181 | ||
|
|
fb8cf1d54a | ||
|
|
013fb54dd1 | ||
|
|
2bf1b2164d | ||
|
|
bab23a1917 | ||
|
|
fa26fd7b42 | ||
|
|
a4a1e27395 | ||
|
|
98bd9fe6f0 | ||
|
|
f944f5bf29 | ||
|
|
484b4ba5ec | ||
|
|
9d3afa6206 | ||
|
|
4c6a8c174d | ||
|
|
3304f4e95a | ||
|
|
e4f86274e3 | ||
|
|
2d575bcc25 | ||
|
|
8a783c2125 | ||
|
|
5230a2402f | ||
|
|
94a750e03e | ||
|
|
afc95b5ed7 | ||
|
|
1d2c58c06a | ||
|
|
4cdc450126 | ||
|
|
7e1be152dc | ||
|
|
c61a11d150 | ||
|
|
2797baca6c | ||
|
|
663264ed39 | ||
|
|
df75520f72 | ||
|
|
a2d52611ee | ||
|
|
fce0a103ff | ||
|
|
1752bf567b | ||
|
|
003194a47f | ||
|
|
c1c6f32e8c | ||
|
|
71edb17182 | ||
|
|
8951e13cf8 | ||
|
|
a998aee45d | ||
|
|
912bf6ca93 | ||
|
|
9cf4fde00c | ||
|
|
5f5cd49e95 | ||
|
|
639ade715b | ||
|
|
a1f2a697a5 | ||
|
|
0fb127cee6 | ||
|
|
d3803b927d | ||
|
|
40a06e3d36 | ||
|
|
11e0623959 | ||
|
|
e9b6418280 | ||
|
|
9f9d18ca71 | ||
|
|
301bdbcfc7 | ||
|
|
56e498a57d | ||
|
|
c0a500728c | ||
|
|
2e0f9a73cd | ||
|
|
6cac16dc3d | ||
|
|
6b275b8a46 | ||
|
|
25fec2e955 | ||
|
|
01337b9c4e | ||
|
|
0f70b20fdb | ||
|
|
61be5b3abf | ||
|
|
2ad49b24f0 | ||
|
|
5058de6f4c | ||
|
|
4c5d6d9e82 | ||
|
|
12c319a8ac |
91
DEMO.md
Normal file
91
DEMO.md
Normal file
@@ -0,0 +1,91 @@
|
||||
# vim: set buftype=nofile colorcolumn= scrolloff=0 noshowcmd:
|
||||
|
||||
vim-easy-align
|
||||
==============
|
||||
|
||||
Where's Lennon?
|
||||
---------------
|
||||
|
||||
Paul McCartney 1942
|
||||
George Harrison 1943
|
||||
Ringo Starr 1940
|
||||
Pete Best 1941
|
||||
|
||||
|
||||
Formatting table
|
||||
----------------
|
||||
```
|
||||
|
||||
| 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 processing |
|
||||
|batch | Boolean | false | enables batch processing mode |
|
||||
|batch_size | Fixnum | nil | maximum number of items in batch|
|
||||
|logger | Logger | nil | logger instance for debug logs |
|
||||
|
||||
```
|
||||
Operators with = sign
|
||||
---------------------
|
||||
```ruby
|
||||
|
||||
a =
|
||||
a = 1
|
||||
bbbb = 2
|
||||
ccccccc = 3
|
||||
ccccccccccccccc
|
||||
ddd = 4
|
||||
eeee === eee = eee = eee=f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == 888
|
||||
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
|
||||
|
||||
```
|
||||
Formatting YAML (or JSON)
|
||||
-------------------------
|
||||
```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
|
||||
|
||||
```
|
||||
Using blockwise-visual mode or negative N-th parameter
|
||||
------------------------------------------------------
|
||||
```ruby
|
||||
|
||||
options = { :caching => nil,
|
||||
:versions => 3,
|
||||
"cache=blocks" => false }.merge(options)
|
||||
|
||||
```
|
||||
Commas
|
||||
------
|
||||
|
||||
aaa, bb,c
|
||||
d,eeeeeee
|
||||
fffff, gggggggggg,
|
||||
h, , ii
|
||||
j,,k
|
||||
|
||||
|
||||
10
EXAMPLES.md
10
EXAMPLES.md
@@ -166,8 +166,8 @@ 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>=`
|
||||
@@ -240,10 +240,10 @@ 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
|
||||
@@ -285,7 +285,7 @@ let g:easy_align_ignore_unmatched = 0
|
||||
|
||||
" 3. Update the alignment rule with ignore_unmatched option
|
||||
let g:easy_align_delimiters['#'] = {
|
||||
\ 'pattern': '#', 'ignores': ['String'], 'ignore_unmatched': 0 }
|
||||
\ 'pattern': '#', 'ignore_groups': ['String'], 'ignore_unmatched': 0 }
|
||||
```
|
||||
|
||||
Then we get,
|
||||
|
||||
519
README.md
519
README.md
@@ -6,14 +6,14 @@ A simple, easy-to-use Vim alignment plugin.
|
||||
Demo
|
||||
----
|
||||
|
||||

|
||||

|
||||
|
||||
(Too fast? Slower GIF is [here](https://raw.github.com/junegunn/vim-easy-align/gif/vim-easy-align-slow.gif))
|
||||
(Too fast? Slower GIF is [here](https://raw.github.com/junegunn/i/master/vim-easy-align.gif))
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- Makes the common case easy
|
||||
- Easy to use
|
||||
- Comes with a predefined set of alignment rules
|
||||
- Provides a fast and intuitive interface
|
||||
- Extensible
|
||||
@@ -22,34 +22,54 @@ Features
|
||||
- Optimized for code editing
|
||||
- Takes advantage of syntax highlighting feature to avoid unwanted alignments
|
||||
|
||||
### _"I already have a similar one. Should I switch?"_
|
||||
|
||||
Maybe or maybe not. See [related work](https://github.com/junegunn/vim-easy-align#related-work) section.
|
||||
|
||||
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).
|
||||
and extract in ~/.vim or
|
||||
[use](https://github.com/tpope/vim-pathogen)
|
||||
[your](https://github.com/gmarik/vundle)
|
||||
[favorite](https://github.com/junegunn/vim-plug)
|
||||
[plugin](https://github.com/Shougo/neobundle.vim)
|
||||
[manager](https://github.com/MarcWeber/vim-addon-manager).
|
||||
|
||||
### With Vundle
|
||||
|
||||
Add the following line to your .vimrc,
|
||||
|
||||
```vim
|
||||
Bundle 'junegunn/vim-easy-align'
|
||||
```
|
||||
|
||||
then execute `:BundleInstall` command.
|
||||
- [Pathogen](https://github.com/tpope/vim-pathogen)
|
||||
- `git clone https://github.com/junegunn/vim-easy-align.git ~/.vim/bundle/vim-easy-align`
|
||||
- [Vundle](https://github.com/gmarik/vundle)
|
||||
1. Add `Bundle 'junegunn/vim-easy-align'` to .vimrc
|
||||
2. Run `:BundleInstall`
|
||||
- [NeoBundle](https://github.com/Shougo/neobundle.vim)
|
||||
1. Add `NeoBundle 'junegunn/vim-easy-align'` to .vimrc
|
||||
2. Run `:NeoBundleInstall`
|
||||
- [vim-plug](https://github.com/junegunn/vim-plug)
|
||||
1. Add `Plug 'junegunn/vim-easy-align'` to .vimrc
|
||||
2. Run `:PlugInstall`
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
_vim-easy-align_ defines `:EasyAlign` command (and the right-align
|
||||
variant `:EasyAlign!`) in the visual mode.
|
||||
variant `:EasyAlign!`) for visual mode.
|
||||
|
||||
| Mode | Command |
|
||||
| ------------------------- | ------------------------------------------------ |
|
||||
| Interactive mode | `:EasyAlign[!] [OPTIONS]` |
|
||||
| Using predefined rules | `:EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS]` |
|
||||
| Using regular expressions | `:EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS]` |
|
||||
| Using predefined rules | `:EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]` |
|
||||
| Using regular expressions | `:EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]` |
|
||||
| Live interactive mode | `:LiveEasyAlign[!] [...]` |
|
||||
|
||||
### Concept of _alignment rule_
|
||||
|
||||
An *alignment rule* is a predefined set of options for common alignment tasks,
|
||||
which is identified by a single character, *DELIMITER KEY*, such as `<space>`,
|
||||
`=`, `:`, `.`, `|`, `&`, and `,`.
|
||||
|
||||
Think of it as a shortcut. Instead of writing regular expression and setting
|
||||
several options, you can just type in a single character.
|
||||
|
||||
### Interactive mode
|
||||
|
||||
@@ -58,7 +78,7 @@ For convenience, it is advised that you define a mapping for triggering it in
|
||||
your `.vimrc`.
|
||||
|
||||
```vim
|
||||
vnoremap <silent> <Enter> :EasyAlign<cr>
|
||||
vnoremap <silent> <Enter> :EasyAlign<Enter>
|
||||
```
|
||||
|
||||
(Of course you can use any key combination as the trigger. e.g. `<Leader>a`)
|
||||
@@ -66,8 +86,8 @@ vnoremap <silent> <Enter> :EasyAlign<cr>
|
||||
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. Optional: Enter keys to select 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,7 +96,7 @@ 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>`, `=`, `:`, `.`, `|`, `&`, `,`)
|
||||
|
||||
Alignment rules for the following delimiters have been defined to meet the most needs.
|
||||
|
||||
@@ -87,40 +107,99 @@ Alignment rules for the following delimiters have been defined to meet the most
|
||||
| `:` | Suitable for formatting JSON or YAML |
|
||||
| `.` | Multi-line method chaining |
|
||||
| `,` | Multi-line method arguments |
|
||||
| `&` | LaTeX tables (matches `&` and `\\`) |
|
||||
| | | Table markdown |
|
||||
|
||||
You can override these default rules or define your own rules with
|
||||
`g:easy_align_delimiters`, which will be described in the later section.
|
||||
`g:easy_align_delimiters`, which will be described in
|
||||
[the later section](https://github.com/junegunn/vim-easy-align#extending-alignment-rules).
|
||||
|
||||
#### Example command sequences
|
||||
|
||||
| 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!**=` |
|
||||
| ... | ... | |
|
||||
| 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>-2<space>` | Alignment around the 2nd to last whitespaces | `:'<,'>EasyAlign-2\ ` |
|
||||
| `<Enter>:` | Alignment around 1st colon (`key: value`) | `:'<,'>EasyAlign:` |
|
||||
| `<Enter><Right>:` | Alignment around 1st colon (`key : value`) | `:'<,'>EasyAlign:s0l1` |
|
||||
| `<Enter>=` | Alignment around 1st operators with = | `:'<,'>EasyAlign=` |
|
||||
| `<Enter>2=` | Alignment around 2nd operators with = | `:'<,'>EasyAlign2=` |
|
||||
| `<Enter>3=` | Alignment around 3rd operators with = | `:'<,'>EasyAlign3=` |
|
||||
| `<Enter>*=` | Alignment around all operators with = | `:'<,'>EasyAlign*=` |
|
||||
| `<Enter>**=` | Left-right alternating alignment around all = operators | `:'<,'>EasyAlign**=` |
|
||||
| `<Enter><Enter>=` | Right alignment around 1st equals signs | `:'<,'>EasyAlign!=` |
|
||||
| `<Enter><Enter>**=` | Right-left alternating alignment around all = operators | `:'<,'>EasyAlign!**=` |
|
||||
|
||||
### Non-interactive mode
|
||||
#### Using regular expressions
|
||||
|
||||
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.
|
||||
Instead of finishing the command with a predefined delimiter key, you can type
|
||||
in a regular expression after `<CTRL-/>` or `<CTRL-X>` key.
|
||||
For example, if you want to align text around all occurrences of numbers:
|
||||
|
||||
- `<Enter>`
|
||||
- `*`
|
||||
- `<CTRL-/>` (or `<CTRL-X>` on GVim)
|
||||
- `[0-9]\+`
|
||||
|
||||
#### 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](https://github.com/junegunn/vim-easy-align#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-O` | `mode_sequence` | 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 }` |
|
||||
|
||||
After a successful alignment, you can repeat the same operation using the
|
||||
repeatable, non-interactive command recorded in `g:easy_align_last_command`.
|
||||
|
||||
```vim
|
||||
:<C-R>=g:easy_align_last_command<Enter><Enter>
|
||||
```
|
||||
|
||||
### 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 `:LiveEasyAlign` command which takes
|
||||
the same parameters as `:EasyAlign`. I suggest you define a mapping such as
|
||||
follows in addition to the one for `:EasyAlign` command.
|
||||
|
||||
```vim
|
||||
vnoremap <silent> <Leader><Enter> :LiveEasyAlign<Enter>
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
### Using `EasyAlign` in command line
|
||||
|
||||
Instead of going into the interactive mode, you can just type in arguments to
|
||||
`:EasyAlign` command.
|
||||
|
||||
```vim
|
||||
" Using predefined alignment rules
|
||||
:EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS]
|
||||
:EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]
|
||||
|
||||
" Using arbitrary regular expressions
|
||||
:EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS]
|
||||
:EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]
|
||||
```
|
||||
|
||||
For example, when aligning the following lines around colons and semi-colons,
|
||||
@@ -135,13 +214,14 @@ try these commands:
|
||||
- `: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.
|
||||
You can also provide a number of alignment options, [which will be discussed in
|
||||
detail later](https://github.com/junegunn/vim-easy-align#alignment-options),
|
||||
to EasyAlign command in Vim dictionary format.
|
||||
|
||||
- `:EasyAlign * /[:;]\+/ { 'stick_to_left': 1, 'left_margin': '' }`
|
||||
- `:EasyAlign * /[:;]\+/ { 'stick_to_left': 1, 'left_margin': 0 }`
|
||||
|
||||
Then we get:
|
||||
Which means that the matched delimiter should be positioned right next to the
|
||||
preceding token, without margin on the left. So we get:
|
||||
|
||||
apple;: banana:: cake
|
||||
data;; exchange:; format
|
||||
@@ -154,7 +234,33 @@ You can even omit spaces between the arguments, so concisely (or cryptically):
|
||||
|
||||
- `: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*/[:;]\+/s1l0`
|
||||
|
||||
The following table summarizes the shorthand notation.
|
||||
|
||||
| Option | Expression |
|
||||
| ---------------- | ---------- |
|
||||
| filter | `[gv]/.*/` |
|
||||
| left_margin | `l[0-9]+` |
|
||||
| right_margin | `r[0-9]+` |
|
||||
| stick_to_left | `s[01]` |
|
||||
| ignore_unmatched | `iu[01]` |
|
||||
| ignore_groups | `ig\[.*\]` |
|
||||
| delimiter_align | `d[lrc]` |
|
||||
| mode_sequence | `m[lrc*]*` |
|
||||
| indentation | `i[ksdn]` |
|
||||
|
||||
For your information, the same thing can be done in the interactive mode as well
|
||||
with the following key combination.
|
||||
|
||||
- `<Enter>`
|
||||
- `*`
|
||||
- `<Left>`
|
||||
- `<CTRL-/>` (or `<CTRL-X>` on GVim)
|
||||
- `[:;]\+`
|
||||
|
||||
### Partial alignment in blockwise-visual mode
|
||||
|
||||
@@ -181,40 +287,89 @@ 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>-=`
|
||||
|
||||
### EasyAlign as Vim operator
|
||||
|
||||
You can define an operator function which executes EasyAlign command, so that it
|
||||
can be used with a Vim movement.
|
||||
|
||||
```vim
|
||||
function! s:easy_align_1st_eq(type, ...)
|
||||
'[,']EasyAlign=
|
||||
endfunction
|
||||
nnoremap <Leader>= :set opfunc=<SID>easy_align_1st_eq<Enter>g@
|
||||
|
||||
function! s:easy_align_1st_colon(type, ...)
|
||||
'[,']EasyAlign:
|
||||
endfunction
|
||||
nnoremap <Leader>: :set opfunc=<SID>easy_align_1st_colon<Enter>g@
|
||||
```
|
||||
|
||||
Now without going into visual mode, you can align the lines in the paragraph
|
||||
by `<Leader>=ip` or `<Leader>:ip`.
|
||||
|
||||
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 |
|
||||
| `mode_sequence` | string | | 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>` | `s[01]` | |
|
||||
| `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` |
|
||||
| `mode_sequence` | `CTRL-O` | `m[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 input `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
|
||||
|
||||
@@ -226,7 +381,7 @@ highlighted as code comments or strings are ignored.
|
||||
" 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']
|
||||
let g:easy_align_ignore_groups = ['Comment', 'String']
|
||||
```
|
||||
|
||||
For example, the following paragraph
|
||||
@@ -257,13 +412,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
|
||||
{
|
||||
@@ -280,10 +437,18 @@ Satisfied? :satisfied:
|
||||
|
||||
### 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 +472,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 +512,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 +520,7 @@ banana += apple
|
||||
cake ||= banana
|
||||
```
|
||||
|
||||
And on `:EasyAlign={'da':c}`, center-aligned.
|
||||
And on `:EasyAlign=dc`, center-aligned.
|
||||
|
||||
```ruby
|
||||
apple = 1
|
||||
@@ -362,6 +528,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 +552,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 +560,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 +568,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
|
||||
@@ -410,29 +578,11 @@ 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:
|
||||
@@ -458,7 +608,8 @@ To recap:
|
||||
```
|
||||
|
||||
In addition to these, you can fine-tune alignments over multiple occurrences of
|
||||
the delimiters with 'mode_sequence' option.
|
||||
the delimiters with 'mode_sequence' option. (The option can also be set
|
||||
in interactive mode with the special key `CTRL-O`)
|
||||
|
||||
```vim
|
||||
" Left alignment over the first two occurrences of delimiters
|
||||
@@ -467,16 +618,27 @@ the delimiters with 'mode_sequence' option.
|
||||
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
|
||||
:EasyAlign = { 'm': 'rlc' }
|
||||
|
||||
" Using shorthand notation
|
||||
:EasyAlign = mrlc
|
||||
|
||||
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
|
||||
:EasyAlign 2={ 'm': 'rlc' }
|
||||
:EasyAlign 2=mrlc
|
||||
|
||||
" (*) Repeating alignments (default: l, r, or c)
|
||||
" Right, left, center, center, center, center, ...
|
||||
:EasyAlign *={ 'm': 'rlc' }
|
||||
:EasyAlign *=mrlc
|
||||
|
||||
" (**) Alternating alignments (default: lr or rl)
|
||||
" Right, left, center, right, left, center, ...
|
||||
:EasyAlign **={ 'm': 'rlc' }
|
||||
:EasyAlign **=mrlc
|
||||
|
||||
" Right, left, center, center, center, ... repeating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3=mrlc*
|
||||
|
||||
" Right, left, center, right, left, center, ... alternating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3=mrlc**
|
||||
```
|
||||
|
||||
### Extending alignment rules
|
||||
@@ -484,13 +646,16 @@ 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`.
|
||||
|
||||
You may refer to the definitions of the default alignment rules
|
||||
[here](https://github.com/junegunn/vim-easy-align/blob/2.6.1/autoload/easy_align.vim#L29).
|
||||
|
||||
#### Example
|
||||
|
||||
```vim
|
||||
let g:easy_align_delimiters = {
|
||||
\ '>': { 'pattern': '>>\|=>\|>' },
|
||||
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignores': ['String'] },
|
||||
\ '#': { 'pattern': '#\+', 'ignores': ['String'], 'delimiter_align': 'l' },
|
||||
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignore_groups': ['String'] },
|
||||
\ '#': { 'pattern': '#\+', 'ignore_groups': ['String'], 'delimiter_align': 'l' },
|
||||
\ ']': {
|
||||
\ 'pattern': '[[\]]',
|
||||
\ 'left_margin': 0,
|
||||
@@ -511,12 +676,128 @@ let g:easy_align_delimiters = {
|
||||
\ }
|
||||
```
|
||||
|
||||
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
|
||||
------------
|
||||
|
||||
There are two well-known plugins with the same goal as that of vim-easy-align.
|
||||
|
||||
- [DrChip's Alignment Tool for Vim](http://www.drchip.org/astronaut/vim/align.html) (herein will be referred to as "Align")
|
||||
- [Tabular](https://github.com/godlygeek/tabular)
|
||||
|
||||
Both are great plugins with very large user bases. I actually had been a Tabular
|
||||
user for a couple of years before I finally made up my mind to roll out my own.
|
||||
|
||||
So why would someone choose vim-easy-align over those two?
|
||||
|
||||
Feature-by-feature comparison I believe is not quite useful, since a typical
|
||||
user will end up using only a small subset of the features.
|
||||
So I will mention just a few core benefits of vim-easy-align.
|
||||
|
||||
### Ease of use
|
||||
|
||||
As the name implies, vim-easy-align is *easier* to use. Its interactive mode
|
||||
allows you to achieve what you want with just a few keystrokes.
|
||||
The key sequence is mnemonic, so it's easy to remember and execute.
|
||||
It even feels like a native Vim command!
|
||||
|
||||
- *Right-align*: `<Enter><Enter>`
|
||||
- around the *second* occurrences: `2`
|
||||
- of *whitespaces*: `<space>`
|
||||
|
||||
For the simplest cases, Tabular and Align are also easy to use. But sooner or
|
||||
later, you will find yourself scratching your head, trying to come up with some
|
||||
complex regular expressions.
|
||||
|
||||
_"How am I going to align the third to the last word in each line to the right
|
||||
without affecting the ones before it?"_
|
||||
|
||||
### Clean
|
||||
|
||||
vim-easy-align doesn't clutter your workspace with mappings and global
|
||||
variables. All you would need is a single mapping to the interactive EasyAlign
|
||||
command, and even that is totally up to you.
|
||||
|
||||
### Optimized for code editing
|
||||
|
||||
vim-easy-align by default performs syntax-aware alignment, which is invaluable
|
||||
when editing codes.
|
||||
|
||||
Try to come up with a regular expression to correctly format the following code
|
||||
snippet. With vim-easy-align under default configuration and a mapping, it can
|
||||
be done with just two keystrokes: `<Enter>:`
|
||||
|
||||
```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"
|
||||
};
|
||||
```
|
||||
|
||||
(To be fair, Align also can be configured to consider syntax highlighting with
|
||||
`g:AlignSkip` function reference which should point to a custom function that
|
||||
looks up the syntax group of a character on a certain position)
|
||||
|
||||
### Thoroughly tested
|
||||
|
||||
Virtually every aspect of vim-easy-align is being tested with a comprehensive
|
||||
set of test cases using [Vader.vim](https://github.com/junegunn/vader.vim).
|
||||
|
||||
### "Okay. So should I switch?"
|
||||
|
||||
Maybe, but I can't really say. I have no ambition to make vim-easy-align
|
||||
an absolute superior to the others. For some cases, vim-easy-align works better
|
||||
than the others, but for some other cases, Tabular or Align.vim might be a
|
||||
better choice.
|
||||
|
||||
So try it yourself and see if it works for you!
|
||||
|
||||
Author
|
||||
------
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,11 +16,11 @@ EasyAlign *:EasyAlign* *:EasyAlign!*
|
||||
vim-easy-align defines `:EasyAlign` command in the visual mode.
|
||||
(:EasyAlign! is the right-align version.)
|
||||
|
||||
| Mode | Command |
|
||||
| ------------------------- | ---------------------------------------------- |
|
||||
| Interactive mode | :EasyAlign[!] [OPTIONS] |
|
||||
| Using predefined rules | :EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS] |
|
||||
| Using regular expressions | :EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS] |
|
||||
| Mode | Command |
|
||||
| ------------------------- | -------------------------------------------- |
|
||||
| Interactive mode | :EasyAlign[!] [OPTIONS] |
|
||||
| Using predefined rules | :EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS] |
|
||||
| Using regular expressions | :EasyAlign[!] [N-th] /REGEXP/ [OPTIONS] |
|
||||
|
||||
|
||||
Interactive mode
|
||||
@@ -30,13 +30,13 @@ 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`.
|
||||
|
||||
vnoremap <silent> <Enter> :EasyAlign<cr>
|
||||
vnoremap <silent> <Enter> :EasyAlign<Enter>
|
||||
|
||||
With this mapping, you can align selected lines of text with a few keystrokes.
|
||||
|
||||
1. <Enter> key to start interactive EasyAlign command
|
||||
2. Optional Enter keys to select alignment mode (left, right, or center)
|
||||
3. Optional field number (default: 1)
|
||||
2. Optional: Enter keys to select alignment mode (left, right, or center)
|
||||
3. Optional: N-th delimiter (default: 1)
|
||||
1 Around the 1st occurrences of delimiters
|
||||
2 Around the 2nd occurrences of delimiters
|
||||
* Around all occurrences of delimiters
|
||||
@@ -50,6 +50,7 @@ With this mapping, you can align selected lines of text with a few keystrokes.
|
||||
: Suitable for formatting JSON or YAML
|
||||
. Multi-line method chaining
|
||||
, Multi-line method arguments. CSV.
|
||||
& LaTeX tables (matches & and \\)
|
||||
| Table markdown
|
||||
|
||||
(You can override these default rules or define your own rules with
|
||||
@@ -72,18 +73,93 @@ Examples:
|
||||
<Enter><Enter>**= Right-left alternating alignment around all equals signs
|
||||
|
||||
|
||||
Non-interactive mode
|
||||
Instead of finishing the command with a predefined delimiter key, you can type
|
||||
in a regular expression after `<CTRL-/>` or `<CTRL-X>` key.
|
||||
For example, if you want to align text around all occurrences of numbers:
|
||||
|
||||
- <Enter>
|
||||
- *
|
||||
- <CTRL-/> (or <CTRL-X> on Gvim)
|
||||
- [0-9]\+
|
||||
|
||||
|
||||
While in interactive mode, you can adjust some of the alignment options using
|
||||
special shortcut keys listed below. The meanings of the options will be
|
||||
described in the following sections.
|
||||
|
||||
| Key | Option | Values |
|
||||
| ------- | ---------------- | -------------------------------------------- |
|
||||
| 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-O | mode_sequence | Input string of /[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 } |
|
||||
|
||||
*g:easy_align_last_command*
|
||||
|
||||
After a successful alignment, you can repeat the same operation using the
|
||||
repeatable, non-interactive command recorded in `g:easy_align_last_command`.
|
||||
|
||||
:<C-R>=g:easy_align_last_command<Enter><Enter>
|
||||
|
||||
|
||||
Live interactive mode *:LiveEasyAlign* *:LiveEasyAlign!*
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
If you're performing a complex alignment where multiple options should be
|
||||
carefully adjusted, try "live interactive mode" which aligns the text
|
||||
on-the-fly as you type in.
|
||||
|
||||
Live interactive mode can be started with `:LiveEasyAlign` command which
|
||||
takes the same parameters as `:EasyAlign`. I suggest you define the
|
||||
following mapping in addition to the one for `:EasyAlign` command.
|
||||
|
||||
vnoremap <silent> <Leader><Enter> :LiveEasyAlign<Enter>
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Left/right/center mode switch in interactive mode
|
||||
-------------------------------------------------------------------------
|
||||
*g:easy_align_interactive_modes*
|
||||
*g:easy_align_bang_interactive_modes*
|
||||
|
||||
In interactive mode, you can choose the alignment mode you want by pressing
|
||||
enter keys. The non-bang command, `:EasyAlign` starts in left-alignment mode
|
||||
and changes to right and center mode as you press enter keys, while the bang
|
||||
version first starts in right-alignment mode.
|
||||
|
||||
- `:EasyAlign`
|
||||
- Left, Right, Center
|
||||
- `:EasyAlign!`
|
||||
- Right, Left, Center
|
||||
|
||||
If you do not prefer this default mode transition, you can define your own
|
||||
settings as follows.
|
||||
|
||||
let g:easy_align_interactive_modes = ['l', 'r']
|
||||
let g:easy_align_bang_interactive_modes = ['c', 'r']
|
||||
|
||||
|
||||
Using EasyAlign in command line
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
Instead of going into the interactive mode, you can type in arguments to
|
||||
`:EasyAlign` command. In non-interactive mode, you can even use arbitrary
|
||||
regular expressions.
|
||||
`:EasyAlign` command.
|
||||
|
||||
" Using predefined alignment rules
|
||||
:EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS]
|
||||
:EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]
|
||||
|
||||
" Using arbitrary regular expressions
|
||||
:EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS]
|
||||
:EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]
|
||||
|
||||
For example, when aligning the following lines around colons and semi-colons,
|
||||
|
||||
@@ -92,45 +168,57 @@ For example, when aligning the following lines around colons and semi-colons,
|
||||
|
||||
try these commands:
|
||||
|
||||
- :EasyAlign /[:;]\+/
|
||||
- :EasyAlign 2/[:;]\+/
|
||||
- :EasyAlign */[:;]\+/
|
||||
- :EasyAlign **/[:;]\+/
|
||||
: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.
|
||||
You can also provide a number of alignment options, which will be discussed in
|
||||
detail later, to EasyAlign command in Vim dictionary format.
|
||||
|
||||
- :EasyAlign * /[:;]\+/ { 'stick_to_left': 1, 'left_margin': '' }
|
||||
:EasyAlign * /[:;]\+/ { 'stick_to_left': 1, 'left_margin': 0 }
|
||||
|
||||
Then we get:
|
||||
Which means that the matched delimiter should be positioned right next to the
|
||||
preceding token, without margin on the left. So we get:
|
||||
|
||||
apple;: banana:: cake
|
||||
data;; exchange:; format
|
||||
|
||||
Option names are fuzzy-matched, so you can write as follows:
|
||||
|
||||
- :EasyAlign * /[:;]\+/ { 'stl': 1, 'l': '' }
|
||||
:EasyAlign * /[:;]\+/ { 'stl': 1, 'l': '' }
|
||||
|
||||
You can even omit spaces between the arguments, so concisely (or cryptically):
|
||||
|
||||
- :EasyAlign*/[:;]\+/{'s':1,'l':''}
|
||||
:EasyAlign*/[:;]\+/{'s':1,'l':''}
|
||||
|
||||
Available options are as follows.
|
||||
Nice. But let's make it even shorter. Option values can be written in shorthand
|
||||
notation.
|
||||
|
||||
| Atrribute | Type | Default |
|
||||
| ---------------- | ---------------- | ----------------------------- |
|
||||
| left_margin | number or string | 0 |
|
||||
| right_margin | number or string | 0 |
|
||||
| stick_to_left | boolean | 0 |
|
||||
| ignore_unmatched | boolean | 1 |
|
||||
| ignores | array | ['String', 'Comment'] |
|
||||
| delimiter_align | string | 'r' |
|
||||
| | | (right, left, center) |
|
||||
| indentation | string | 'k' |
|
||||
| | | (keep, shallow, deep, none) |
|
||||
| mode_sequence | string | (Depends on field number and |
|
||||
| | | selected alignment mode) |
|
||||
:EasyAlign*/[:;]\+/s1l0
|
||||
|
||||
The following table summarizes the shorthand notation.
|
||||
|
||||
| Option | Expression |
|
||||
| -------------- | ---------- |
|
||||
| filter | [gv]/.*/ |
|
||||
| left_margin | l[0-9]+ |
|
||||
| right_margin | r[0-9]+ |
|
||||
| stick_to_left | s[01] |
|
||||
| ignore_unmatched | iu[01] |
|
||||
| ignore_groups | ig\[.*\] |
|
||||
| delimiter_align | d[lrc] |
|
||||
| mode_sequence | m[lrc*]+ |
|
||||
| indentation | i[ksdn] |
|
||||
|
||||
For your information, the same thing can be done in the interactive mode as well
|
||||
with the following key combination.
|
||||
|
||||
- <Enter>
|
||||
- *
|
||||
- <Left>
|
||||
- <CTRL-/> (or <CTRL-X> on GVim)
|
||||
- [:;]\+
|
||||
|
||||
|
||||
Partial alignment in blockwise-visual mode
|
||||
@@ -140,7 +228,71 @@ In blockwise-visual mode (CTRL-V), EasyAlign command aligns only
|
||||
the selected text in the block, instead of the whole lines in the range.
|
||||
|
||||
|
||||
Ignoring delimiters in comments or strings *g:easy_align_ignores*
|
||||
Alignment options
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
Available options are as follows.
|
||||
|
||||
| Atrribute | Type | Default |
|
||||
| ---------------- | ---------------- | ----------------------------- |
|
||||
| filter | string | |
|
||||
| left_margin | number or string | 1 |
|
||||
| right_margin | number or string | 1 |
|
||||
| stick_to_left | boolean | 0 |
|
||||
| ignore_unmatched | boolean | 1 |
|
||||
| ignore_groups | array | ['String', 'Comment'] |
|
||||
| delimiter_align | string | 'r' |
|
||||
| | | (right, left, center) |
|
||||
| indentation | string | 'k' |
|
||||
| | | (keep, shallow, deep, none) |
|
||||
| mode_sequence | string | (Depends on N-th param and |
|
||||
| | | selected alignment mode) |
|
||||
|
||||
There are 4 ways to set alignment options (from lowest precedence to highest):
|
||||
|
||||
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 | 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> | s[01] | |
|
||||
| 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` |
|
||||
| mode_sequence | CTRL-O | m[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 input 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/
|
||||
|
||||
Examples:
|
||||
|
||||
" 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/
|
||||
|
||||
(You don't need to escape '/'s in the regular expression)
|
||||
|
||||
|
||||
Ignoring delimiters in comments or strings *g:easy_align_ignore_groups*
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
EasyAlign can be configured to ignore delimiters in certain syntax
|
||||
@@ -150,7 +302,7 @@ that are highlighted as code comments or strings are ignored.
|
||||
" 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']
|
||||
let g:easy_align_ignore_groups = ['Comment', 'String']
|
||||
|
||||
For example, the following paragraph
|
||||
|
||||
@@ -176,13 +328,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 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
|
||||
|
||||
{
|
||||
# Quantity of apples: 1
|
||||
@@ -197,10 +351,18 @@ For example if you set 'ignores' option to be an empty list, you get
|
||||
Ignoring unmatched lines *g:easy_align_ignore_unmatched*
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
Lines without any matching delimiter are ignored as well (except in
|
||||
right-align mode).
|
||||
'ignore_unmatched' option determines how EasyAlign command processes lines that
|
||||
do not have N-th delimiter.
|
||||
|
||||
For example, when aligning the following code block around the colons,
|
||||
1. In left-alignment mode, they are ignored
|
||||
2. In right or center-alignment mode, they are not ignored, and the last
|
||||
tokens from those lines are aligned as well as if there is an invisible
|
||||
trailing delimiter at the end of each line
|
||||
3. If 'ignore_unmatched' is 1, they are ignored regardless of the alignment mode
|
||||
4. If 'ignore_unmatched' is 0, they are not ignored regardless of the mode
|
||||
|
||||
Let's take an example.
|
||||
When we align the following code block around the (1st) colons,
|
||||
|
||||
{
|
||||
apple: proc {
|
||||
@@ -220,13 +382,14 @@ this is usually what we want.
|
||||
grapefruits: 3
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
@@ -256,18 +419,20 @@ By default, delimiters are right-aligned as follows.
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
|
||||
However, with ':EasyAlign={'da':l}', delimiters are left-aligned.
|
||||
However, with ':EasyAlign=dl', delimiters are left-aligned.
|
||||
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
|
||||
And on ':EasyAlign={'da':c}', center-aligned.
|
||||
And on ':EasyAlign=dc', center-aligned.
|
||||
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
|
||||
In interactive mode, you can change the option value with `CTRL-D` key.
|
||||
|
||||
|
||||
Adjusting indentation *g:easy_align_indentation*
|
||||
-------------------------------------------------------------------------
|
||||
@@ -291,7 +456,7 @@ But then again we have 'indentation' option. See the following example.
|
||||
eggplant = 5
|
||||
|
||||
# Use the _s_hallowest indentation among the lines
|
||||
# :EasyAlign={'idt':s}
|
||||
# :EasyAlign=is
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
@@ -299,7 +464,7 @@ But then again we have 'indentation' option. See the following example.
|
||||
eggplant = 5
|
||||
|
||||
# Use the _d_eepest indentation among the lines
|
||||
# :EasyAlign={'idt':d}
|
||||
# :EasyAlign=id
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
@@ -307,7 +472,7 @@ But then again we have 'indentation' option. See the following example.
|
||||
eggplant = 5
|
||||
|
||||
# Indentation: _n_one
|
||||
# :EasyAlign={'idt':n}
|
||||
# :EasyAlign=in
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
@@ -317,33 +482,13 @@ But then again we have 'indentation' option. See the following example.
|
||||
|
||||
Notice that 'idt' is fuzzy-matched to 'indentation'.
|
||||
|
||||
|
||||
Left/right/center mode switch in interactive mode
|
||||
-------------------------------------------------------------------------
|
||||
*g:easy_align_interactive_modes*
|
||||
*g:easy_align_bang_interactive_modes*
|
||||
|
||||
In interactive mode, you can choose the alignment mode you want by pressing
|
||||
enter keys. The non-bang command, `:EasyAlign` starts in left-alignment mode
|
||||
and changes to right and center mode as you press enter keys, while the bang
|
||||
version first starts in right-alignment mode.
|
||||
|
||||
- `:EasyAlign`
|
||||
- Left, Right, Center
|
||||
- `:EasyAlign!`
|
||||
- Right, Left, Center
|
||||
|
||||
If you do not prefer this default mode transition, you can define your own
|
||||
settings as follows.
|
||||
|
||||
let g:easy_align_interactive_modes = ['l', 'r']
|
||||
let g:easy_align_bang_interactive_modes = ['c', 'r']
|
||||
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:
|
||||
@@ -367,7 +512,8 @@ To recap:
|
||||
:EasyAlign! **=
|
||||
|
||||
In addition to these, you can fine-tune alignments over multiple occurrences of
|
||||
the delimiters with 'mode_sequence' option.
|
||||
the delimiters with 'mode_sequence' option. (The option can also be set
|
||||
in interactive mode with the special key CTRL-O)
|
||||
|
||||
" Left alignment over the first two occurrences of delimiters
|
||||
:EasyAlign = { 'mode_sequence': 'll' }
|
||||
@@ -375,16 +521,27 @@ the delimiters with 'mode_sequence' option.
|
||||
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
|
||||
:EasyAlign = { 'm': 'rlc' }
|
||||
|
||||
" Using shorthand notation
|
||||
:EasyAlign = mrlc
|
||||
|
||||
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
|
||||
:EasyAlign 2={ 'm': 'rlc' }
|
||||
:EasyAlign 2=mrlc
|
||||
|
||||
" (*) Repeating alignments (default: l, r, or c)
|
||||
" Right, left, center, center, center, center, ...
|
||||
:EasyAlign *={ 'm': 'rlc' }
|
||||
:EasyAlign *=mrlc
|
||||
|
||||
" (**) Alternating alignments (default: lr or rl)
|
||||
" Right, left, center, right, left, center, ...
|
||||
:EasyAlign **={ 'm': 'rlc' }
|
||||
:EasyAlign **=mrlc
|
||||
|
||||
" Right, left, center, center, center, ... repeating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3=mrlc*
|
||||
|
||||
" Right, left, center, right, left, center, ... alternating alignment
|
||||
" over the 3rd to the last occurrences of delimiters
|
||||
:EasyAlign 3=mrlc**
|
||||
|
||||
|
||||
Extending alignment rules *g:easy_align_delimiters*
|
||||
@@ -396,8 +553,8 @@ you can extend the rules by setting a dictionary named
|
||||
|
||||
let g:easy_align_delimiters = {
|
||||
\ '>': { 'pattern': '>>\|=>\|>' },
|
||||
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignores': ['String'] },
|
||||
\ '#': { 'pattern': '#\+', 'ignores': ['String'] },
|
||||
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignore_groups': ['String'] },
|
||||
\ '#': { 'pattern': '#\+', 'ignore_groups': ['String'] },
|
||||
\ ']': {
|
||||
\ 'pattern': '[[\]]',
|
||||
\ 'left_margin': 0,
|
||||
@@ -413,3 +570,14 @@ you can extend the rules by setting a dictionary named
|
||||
\ }
|
||||
|
||||
|
||||
Disabling `foldmethod` during alignment *g:easy_align_bypass_fold*
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
It is reported 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 to 1.
|
||||
|
||||
let g:easy_align_bypass_fold = 1
|
||||
|
||||
|
||||
@@ -26,4 +26,5 @@ 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, <q-args>)
|
||||
command! -nargs=* -range -bang LiveEasyAlign <line1>,<line2>call easy_align#align('<bang>' == '!', 1, <q-args>)
|
||||
|
||||
13
test/README.md
Normal file
13
test/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
Test cases for vim-easy-align
|
||||
=============================
|
||||
|
||||
### Prerequisite
|
||||
|
||||
- [Vader.vim](https://github.com/junegunn/vader.vim)
|
||||
|
||||
### Run
|
||||
|
||||
```vim
|
||||
:Vader*
|
||||
```
|
||||
|
||||
@@ -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 |
|
||||
|
||||
219
test/basic.md
219
test/basic.md
@@ -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 =
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
4Gvipjyvip
|
||||
165
test/commandline.vader
Normal file
165
test/commandline.vader
Normal file
@@ -0,0 +1,165 @@
|
||||
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
|
||||
|
||||
let g:easy_align_delimiters = {}
|
||||
silent! unlet g:easy_align_ignore_groups
|
||||
silent! unlet g:easy_align_ignore_unmatched
|
||||
silent! unlet g:easy_align_indentation
|
||||
silent! unlet g:easy_align_delimiter_align
|
||||
|
||||
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 (shorthand notation of mode_sequence and margin):
|
||||
%EasyAlign/[:;]\+/mrc*l2r2
|
||||
|
||||
Expect:
|
||||
apple ;:;; banana :: cake
|
||||
data ;; exchange :;:: format
|
||||
|
||||
Execute (deep indentation):
|
||||
%EasyAlign/[:;]\+/mrc*l2r2
|
||||
%EasyAlign*/[:;]\+/idmrl*
|
||||
|
||||
Expect:
|
||||
apple ;:;; banana :: cake
|
||||
data ;; exchange :;:: format
|
||||
|
||||
Execute (stick_to_left):
|
||||
%EasyAlign*/[:;]\+/stl1l0dlrm3
|
||||
|
||||
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
|
||||
|
||||
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"
|
||||
};
|
||||
|
||||
Execute:
|
||||
Restore
|
||||
42
test/fixed.vader
Normal file
42
test/fixed.vader
Normal file
@@ -0,0 +1,42 @@
|
||||
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<|
|
||||
20
test/fixme.vader
Normal file
20
test/fixme.vader
Normal file
@@ -0,0 +1,20 @@
|
||||
# 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
|
||||
|
||||
@@ -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()
|
||||
|
||||
1506
test/interactive.vader
Normal file
1506
test/interactive.vader
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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(
|
||||
|
||||
@@ -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
|
||||
```
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
4Gvipjyvip:EasyAlign:
|
||||
@@ -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
|
||||
'
|
||||
161
test/tex.vader
Normal file
161
test/tex.vader
Normal file
@@ -0,0 +1,161 @@
|
||||
# http://en.wikibooks.org/wiki/LaTeX/Tables
|
||||
Execute:
|
||||
Save g:easy_align_delimiters, g:easy_align_bypass_fold
|
||||
let g:easy_align_delimiters = {}
|
||||
silent! unlet g:easy_align_bypass_fold
|
||||
|
||||
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}
|
||||
|
||||
Execute:
|
||||
Restore
|
||||
Reference in New Issue
Block a user