mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-17 14:23:42 -05:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62314afcaf | ||
|
|
cef26cdef9 | ||
|
|
659e2ff513 | ||
|
|
481a88f601 | ||
|
|
6fb4f57b5a | ||
|
|
beb986ebc3 | ||
|
|
5222db47cf | ||
|
|
74003c0297 | ||
|
|
999e1ff68e | ||
|
|
11a74c4176 | ||
|
|
e7e7a80afb | ||
|
|
29e5cd1d19 | ||
|
|
5c6558bd1b | ||
|
|
b6625f6d2b | ||
|
|
d4277a0298 | ||
|
|
d31e6ed257 | ||
|
|
1e2af43a64 | ||
|
|
0fb997d5ab | ||
|
|
90a5487974 | ||
|
|
aad5012615 | ||
|
|
0166077e16 | ||
|
|
3c4b7af9b5 | ||
|
|
5e6e60d620 | ||
|
|
712bab8c72 | ||
|
|
0546969c6b | ||
|
|
8805ec3834 | ||
|
|
96608ee5ef | ||
|
|
7d031956ab | ||
|
|
c4dbfece32 | ||
|
|
a2811dc253 | ||
|
|
5e4ec85956 | ||
|
|
b3281fb19a | ||
|
|
10a4176159 |
178
EXAMPLES.md
178
EXAMPLES.md
@@ -1,7 +1,9 @@
|
||||
vim-easy-align examples
|
||||
=======================
|
||||
|
||||
The description in this document assumes that you have defined this mapping.
|
||||
Open this document in your Vim and try it yourself.
|
||||
|
||||
This document assumes that you have defined the following mapping.
|
||||
|
||||
```vim
|
||||
vnoremap <silent> <Enter> :EasyAlign<cr>
|
||||
@@ -12,20 +14,17 @@ function.
|
||||
|
||||
```vim
|
||||
function! GFM()
|
||||
let syntaxes = {
|
||||
\ 'ruby': 'syntax/ruby.vim',
|
||||
\ 'yaml': 'syntax/yaml.vim',
|
||||
\ 'vim': 'syntax/vim.vim',
|
||||
\ 'c': 'syntax/c.vim'
|
||||
\ }
|
||||
let langs = ['ruby', 'yaml', 'vim', 'c']
|
||||
|
||||
for [lang, syn] in items(syntaxes)
|
||||
for lang in langs
|
||||
unlet b:current_syntax
|
||||
silent! exec printf("syntax include @%s %s", lang, syn)
|
||||
silent! exec printf("syntax include @%s syntax/%s.vim", lang, lang)
|
||||
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
|
||||
```
|
||||
|
||||
@@ -42,6 +41,7 @@ Try these commands:
|
||||
- `<Enter>-2<space>`
|
||||
- `<Enter><Enter><space>`
|
||||
- `<Enter><Enter>*<space>`
|
||||
- `<Enter><Enter><Enter>*<space>`
|
||||
|
||||
### Example
|
||||
|
||||
@@ -62,6 +62,7 @@ Try these commands:
|
||||
- `<Enter>**|`
|
||||
- `<Enter><Enter>*|`
|
||||
- `<Enter><Enter>**|`
|
||||
- `<Enter><Enter><Enter>*|`
|
||||
|
||||
### Example
|
||||
|
||||
@@ -91,6 +92,7 @@ Try these commands:
|
||||
- `<Enter>*=`
|
||||
- `<Enter>**=`
|
||||
- `<Enter><Enter>**=`
|
||||
- `<Enter><Enter><Enter>*=`
|
||||
|
||||
### Example
|
||||
|
||||
@@ -130,7 +132,6 @@ Try `<Enter>:` here, to align text around only the first occurrences of colons.
|
||||
In this case, you don't want to align around all the colons: `<Enter>*:`.
|
||||
|
||||
```yaml
|
||||
|
||||
mysql:
|
||||
# JDBC driver for MySQL database:
|
||||
driver: com.mysql.jdbc.Driver
|
||||
@@ -138,7 +139,6 @@ mysql:
|
||||
url: jdbc:mysql://localhost/test
|
||||
database: test
|
||||
"user:pass":r00t:pa55
|
||||
|
||||
```
|
||||
|
||||
Formatting multi-line method chaining
|
||||
@@ -166,39 +166,35 @@ my_object
|
||||
```
|
||||
|
||||
|
||||
Partial alignment in block-visual mode / Negative field index
|
||||
-------------------------------------------------------------
|
||||
Using blockwise-visual mode or negative field index
|
||||
---------------------------------------------------
|
||||
|
||||
You can try one of these:
|
||||
- Select text around `=>` in block-wise visual mode (`<Ctrl>-V`) and `<Enter>=`
|
||||
- `<Enter>-=`
|
||||
You can try either:
|
||||
- select text around `=>` in blockwise-visual mode (`CTRL-V`) and `<Enter>=`
|
||||
- or `<Enter>-=`
|
||||
|
||||
```ruby
|
||||
|
||||
options = { :caching => nil,
|
||||
:versions => 3,
|
||||
"cache=blocks" => false }.merge(options)
|
||||
|
||||
```
|
||||
|
||||
Commas
|
||||
------
|
||||
|
||||
There is also a predefined rule for commas, try `<Enter>*,` for the following
|
||||
There is also a predefined rule for commas, try `<Enter>*,` on the following
|
||||
lines.
|
||||
|
||||
```
|
||||
|
||||
aaa, bb,c
|
||||
d,eeeeeee
|
||||
fffff, gggggggggg,
|
||||
h, , ii
|
||||
j,,k
|
||||
|
||||
```
|
||||
|
||||
Ignoring delimiters in comments and strings
|
||||
-------------------------------------------
|
||||
Ignoring delimiters in comments or strings
|
||||
------------------------------------------
|
||||
|
||||
Delimiters highlighted as comments or strings are ignored by default, try
|
||||
`<Enter>*=` on the following lines.
|
||||
@@ -213,6 +209,8 @@ aaaaa /* bbbbb */ == ccccc /* != eeeee = */ === fffff
|
||||
|
||||
```
|
||||
|
||||
This only works when syntax highlighting is enabled.
|
||||
|
||||
Aligning in-line comments
|
||||
-------------------------
|
||||
|
||||
@@ -222,10 +220,10 @@ banana = 'Gros Michel' # comment 2
|
||||
```
|
||||
|
||||
So, how do we align the trailing comments in the above lines?
|
||||
Simply try `<Enter>-<space>`! The spaces in the comments are ignored, so the
|
||||
Simply try `<Enter>-<space>`. The spaces in the comments are ignored, so the
|
||||
trailing comment in each line is considered to be a single chunk.
|
||||
|
||||
But this doesn't work in the following case.
|
||||
But that doesn't work in the following case.
|
||||
|
||||
```ruby
|
||||
apple = 1 # comment not aligned
|
||||
@@ -234,7 +232,7 @@ banana = 'Gros Michel' # comment 2
|
||||
```
|
||||
|
||||
That is because the second line doesn't have trailing comment, and
|
||||
the last space (`-`) for that line is the one just before `'F#AD'`.
|
||||
the last (`-`) space for that line is the one just before `'F#AD'`.
|
||||
|
||||
So, let's define a custom mapping for `#`.
|
||||
|
||||
@@ -242,7 +240,7 @@ So, let's define a custom mapping for `#`.
|
||||
if !exists('g:easy_align_delimiters')
|
||||
let g:easy_align_delimiters = {}
|
||||
endif
|
||||
let g:easy_align_delimiters['#'] = { 'pattern': '#', 'ignores': ['String'] } }
|
||||
let g:easy_align_delimiters['#'] = { 'pattern': '#', 'ignores': ['String'] }
|
||||
```
|
||||
|
||||
Notice that the rule overrides `ignores` attribute in order *not to ignore*
|
||||
@@ -256,7 +254,7 @@ apricot = 'DAD' + 'F#AD'
|
||||
banana = 'string' # comment 2
|
||||
```
|
||||
|
||||
If you don't want to define a rule, you can do the same with the following
|
||||
If you don't want to define the rule, you can do the same with the following
|
||||
command:
|
||||
|
||||
```vim
|
||||
@@ -265,17 +263,29 @@ command:
|
||||
:EasyAlign/#/{'is':['String']}
|
||||
```
|
||||
|
||||
In this case, the second line is ignored as it doesn't contain `#`. (The one
|
||||
In this case, the second line is ignored as it doesn't contain a `#`. (The one
|
||||
highlighted as String is ignored.) If you don't want the second line to be
|
||||
ignored, set `g:easy_align_ignore_unmatched` to 0, or use the following
|
||||
commands:
|
||||
ignored, there are three options:
|
||||
|
||||
1. Set global `g:easy_align_ignore_unmatched` flag to 0
|
||||
2. Use `:EasyAlign` command with `ignore_unmatched` option
|
||||
3. Update the alignment rule with `ignore_unmatched` option
|
||||
|
||||
```vim
|
||||
" Using predefined rule with delimiter key #
|
||||
:EasyAlign#{'iu':0}`
|
||||
" 1. Set global g:easy_align_ignore_unmatched to zero
|
||||
let g:easy_align_ignore_unmatched = 0
|
||||
|
||||
" Using regular expression /#/
|
||||
:EasyAlign/#/{'is':['String'],'iu':0}`
|
||||
" 2. Using :EasyAlign command with ignore_unmatched option
|
||||
" 2-1. Using predefined rule with delimiter key #
|
||||
" - "iu" is fuzzy-matched to "*i*gnore_*u*nmatched"
|
||||
:EasyAlign#{'iu':0}
|
||||
|
||||
" 2-2. Using regular expression /#/
|
||||
:EasyAlign/#/{'is':['String'],'iu':0}
|
||||
|
||||
" 3. Update the alignment rule with ignore_unmatched option
|
||||
let g:easy_align_delimiters['#'] = {
|
||||
\ 'pattern': '#', 'ignores': ['String'], 'ignore_unmatched': 0 }
|
||||
```
|
||||
|
||||
Then we get,
|
||||
@@ -286,3 +296,101 @@ apricot = 'DAD' + 'F#AD'
|
||||
banana = 'string' # comment 2
|
||||
```
|
||||
|
||||
Aligning C-style variable definition
|
||||
------------------------------------
|
||||
|
||||
Take the following example:
|
||||
|
||||
```c
|
||||
const char* str = "Hello";
|
||||
int64_t count = 1 + 2;
|
||||
static double pi = 3.14;
|
||||
```
|
||||
|
||||
We can align these lines with the predefined `=` rule. Select the lines and
|
||||
press `<Enter>=`
|
||||
|
||||
```c
|
||||
const char* str = "Hello";
|
||||
int64_t count = 1 + 2;
|
||||
static double pi = 3.14;
|
||||
```
|
||||
|
||||
Not bad. However, the names of the variables, `str`, `count`, and `pi` are not
|
||||
aligned with each other. Can we do better? We can clearly see that simple
|
||||
`<Enter><space>` won't properly align those names.
|
||||
So let's define an alignment rule than can handle this case.
|
||||
|
||||
```vim
|
||||
let g:easy_align_delimiters['d'] = {
|
||||
\ 'pattern': '\(const\|static\)\@<! ',
|
||||
\ 'left_margin': 0, 'right_margin': 0
|
||||
\ }
|
||||
```
|
||||
|
||||
This new rule aligns text around spaces that are *not* preceded by
|
||||
`const` or `static`. Let's try it with `<Enter>d`.
|
||||
|
||||
```c
|
||||
const char* str = "Hello";
|
||||
int64_t count = 1 + 2;
|
||||
static double pi = 3.14;
|
||||
```
|
||||
|
||||
Okay, the names are now aligned. We select the lines again with `gv`, and then
|
||||
press `<Enter>=` to finish our alignment.
|
||||
|
||||
```c
|
||||
const char* str = "Hello";
|
||||
int64_t count = 1 + 2;
|
||||
static double pi = 3.14;
|
||||
```
|
||||
|
||||
So far, so good. However, this rule is not sufficient to handle more complex
|
||||
cases involving C++ templates or Java generics. Take the following example:
|
||||
|
||||
```c
|
||||
const char* str = "Hello";
|
||||
int64_t count = 1 + 2;
|
||||
static double pi = 3.14;
|
||||
static std::map<std::string, float>* scores = pointer;
|
||||
```
|
||||
|
||||
We see that our rule above doesn't work anymore.
|
||||
|
||||
```c
|
||||
const char* str = "Hello";
|
||||
int64_t count = 1 + 2;
|
||||
static double pi = 3.14;
|
||||
static std::map<std::string, float>* scores = pointer;
|
||||
```
|
||||
|
||||
So what do we do? Let's try to improve our alignment rule.
|
||||
|
||||
```vim
|
||||
let g:easy_align_delimiters['d'] = {
|
||||
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
|
||||
\ 'left_margin': 0, 'right_margin': 0
|
||||
\ }
|
||||
```
|
||||
|
||||
Now the new rule has changed to align text around spaces that are followed
|
||||
by some non-whitespace characters and then an equals sign or a semi-colon.
|
||||
Try `<Enter>d`
|
||||
|
||||
```c
|
||||
const char* str = "Hello";
|
||||
int64_t count = 1 + 2;
|
||||
static double pi = 3.14;
|
||||
static std::map<std::string, float>* scores = pointer;
|
||||
```
|
||||
|
||||
We're right on track, now press `gv<Enter>=` and voila!
|
||||
|
||||
```c
|
||||
const char* str = "Hello";
|
||||
int64_t count = 1 + 2;
|
||||
static double pi = 3.14;
|
||||
static std::map<std::string, float>* scores = pointer;
|
||||
```
|
||||
|
||||
|
||||
302
README.md
302
README.md
@@ -1,23 +1,26 @@
|
||||
vim-easy-align
|
||||
==============
|
||||
|
||||
A simple, easy-to-use Vim alignment plugin without too much ambition.
|
||||
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))
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
- Makes the common case easy
|
||||
- Comes with a predefined set of alignment rules
|
||||
- Provides a fast and intuitive interface
|
||||
- Extensible
|
||||
- You can define your own rules
|
||||
- Supports arbitrary regular expressions
|
||||
- Optimized for code editing
|
||||
- Designed to require minimal keystrokes
|
||||
- Extensible alignment rules
|
||||
- Supports arbitrary regular expressions
|
||||
- Aligns text around either _all or n-th_ occurrence(s) of the delimiter
|
||||
- Ignores delimiters in certain syntax highlight groups (e.g. comments, strings)
|
||||
- Ignores lines without a matching delimiter
|
||||
- Takes advantage of syntax highlighting feature to avoid unwanted alignments
|
||||
|
||||
Installation
|
||||
------------
|
||||
@@ -28,21 +31,25 @@ or [Pathogen](https://github.com/tpope/vim-pathogen).
|
||||
|
||||
### With Vundle
|
||||
|
||||
Add the following line to your .vimrc,
|
||||
|
||||
```vim
|
||||
Bundle 'junegunn/vim-easy-align'
|
||||
```
|
||||
|
||||
then execute `:BundleInstall` command.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
_vim-easy-align_ defines `:EasyAlign` command (and the right-justification
|
||||
_vim-easy-align_ defines `:EasyAlign` command (and the right-align
|
||||
variant `:EasyAlign!`) in the visual mode.
|
||||
|
||||
| Mode | Command |
|
||||
| ------------------------- | --------------------------------------------- |
|
||||
| Interactive mode | `:EasyAlign` |
|
||||
| Using predefined rules | `:EasyAlign [FIELD#] DELIMITER_KEY [OPTIONS]` |
|
||||
| Using regular expressions | `:EasyAlign [FIELD#] /REGEXP/ [OPTIONS]` |
|
||||
| Mode | Command |
|
||||
| ------------------------- | ------------------------------------------------ |
|
||||
| Interactive mode | `:EasyAlign[!] [OPTIONS]` |
|
||||
| Using predefined rules | `:EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS]` |
|
||||
| Using regular expressions | `:EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS]` |
|
||||
|
||||
### Interactive mode
|
||||
|
||||
@@ -54,10 +61,12 @@ your `.vimrc`.
|
||||
vnoremap <silent> <Enter> :EasyAlign<cr>
|
||||
```
|
||||
|
||||
With the mapping, you can align selected lines of text with a few keystrokes.
|
||||
(Of course you can use any key combination as the trigger. e.g. `<Leader>a`)
|
||||
|
||||
With the mapping, you can align selected lines of text with only a few keystrokes.
|
||||
|
||||
1. `<Enter>` key to start interactive EasyAlign command
|
||||
1. Optional Enter keys to toggle right-justification mode
|
||||
1. Optional Enter keys to select alignment mode (left, right, or center)
|
||||
1. Optional field number (default: 1)
|
||||
- `1` Around the 1st occurrences of delimiters
|
||||
- `2` Around the 2nd occurrences of delimiters
|
||||
@@ -80,6 +89,9 @@ Alignment rules for the following delimiters have been defined to meet the most
|
||||
| `,` | Multi-line method arguments |
|
||||
| | | Table markdown |
|
||||
|
||||
You can override these default rules or define your own rules with
|
||||
`g:easy_align_delimiters`, which will be described in the later section.
|
||||
|
||||
#### Example command sequences
|
||||
|
||||
| With visual map | Description | Equivalent command |
|
||||
@@ -93,7 +105,7 @@ Alignment rules for the following delimiters have been defined to meet the most
|
||||
| `<Enter>3=` | Alignment around 3rd equals signs (and the likes) | `:'<,'>EasyAlign3=` |
|
||||
| `<Enter>*=` | Alignment around all equals signs (and the likes) | `:'<,'>EasyAlign*=` |
|
||||
| `<Enter>**=` | Left-right alternating alignment around all equals signs | `:'<,'>EasyAlign**=` |
|
||||
| `<Enter><Enter>=` | Right-justified alignment around 1st equals signs | `:'<,'>EasyAlign!=` |
|
||||
| `<Enter><Enter>=` | Right alignment around 1st equals signs | `:'<,'>EasyAlign!=` |
|
||||
| `<Enter><Enter>**=` | Right-left alternating alignment around all equals signs | `:'<,'>EasyAlign!**=` |
|
||||
| ... | ... | |
|
||||
|
||||
@@ -134,7 +146,7 @@ Then we get:
|
||||
apple;: banana:: cake
|
||||
data;; exchange:; format
|
||||
|
||||
Options keys are fuzzy-matched, so you can write as follows:
|
||||
Option names are fuzzy-matched, so you can write as follows:
|
||||
|
||||
- `:EasyAlign * /[:;]\+/ { 'stl': 1, 'l': 0 }`
|
||||
|
||||
@@ -142,17 +154,7 @@ You can even omit spaces between the arguments, so concisely (or cryptically):
|
||||
|
||||
- `:EasyAlign*/[:;]\+/{'s':1,'l':0}`
|
||||
|
||||
Available options are as follows.
|
||||
|
||||
| Atrribute | Type | Default |
|
||||
| ---------------- | ---------------- | ----------------------- |
|
||||
| left_margin | number or string | 0 |
|
||||
| right_margin | number or string | 0 |
|
||||
| stick_to_left | boolean | 0 |
|
||||
| ignore_unmatched | boolean | 1 |
|
||||
| ignores | array | `['String', 'Comment']` |
|
||||
|
||||
(The last two options will be described shortly in the following sections.)
|
||||
Available options will be shown later in the document.
|
||||
|
||||
### Partial alignment in blockwise-visual mode
|
||||
|
||||
@@ -181,14 +183,38 @@ 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>-=`
|
||||
|
||||
Global options
|
||||
--------------
|
||||
Alignment options
|
||||
-----------------
|
||||
|
||||
| Option | Type | Default | Description |
|
||||
| ----------------------------- | ---------- | ----------------------- | -------------------------------------------------- |
|
||||
| g:easy_align_ignores | list | `['String', 'Comment']` | Ignore delimiters in these syntax highlight groups |
|
||||
| g:easy_align_ignore_unmatched | boolean | `1` | Ignore lines without matching delimiter |
|
||||
| g:easy_align_delimiters | dictionary | `{}` | Extend or override alignment rules |
|
||||
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 |
|
||||
|
||||
Some of the options can be specified using corresponding global variables.
|
||||
|
||||
| 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` |
|
||||
|
||||
### Ignoring delimiters in comments or strings
|
||||
|
||||
@@ -231,21 +257,13 @@ becomes as follows on `<Enter>:` (or `:EasyAlign:`)
|
||||
|
||||
Naturally, this feature only works when syntax highlighting is enabled.
|
||||
|
||||
You can change the default rule by either defining global `g:easy_align_ignores`
|
||||
array,
|
||||
You can change the default rule by using one of these 3 methods.
|
||||
|
||||
```vim
|
||||
" Ignore nothing!
|
||||
let g:easy_align_ignores = []
|
||||
```
|
||||
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':[]}`
|
||||
|
||||
or providing `ignores` option directly to `:EasyAlign` command
|
||||
|
||||
```vim
|
||||
:EasyAlign:{'is':[]}
|
||||
```
|
||||
|
||||
Then you get,
|
||||
For example if you set `ignores` option to be an empty list, you get
|
||||
|
||||
```ruby
|
||||
{
|
||||
@@ -263,7 +281,7 @@ Satisfied? :satisfied:
|
||||
### Ignoring unmatched lines
|
||||
|
||||
Lines without any matching delimiter are ignored as well (except in
|
||||
right-justification mode).
|
||||
right-align mode).
|
||||
|
||||
For example, when aligning the following code block around the colons,
|
||||
|
||||
@@ -289,20 +307,12 @@ this is usually what we want.
|
||||
}
|
||||
```
|
||||
|
||||
However, this default behavior is also configurable.
|
||||
However, this default behavior is also configurable by using one of these 3
|
||||
methods.
|
||||
|
||||
One way is to set the global `g:easy_align_ignore_unmatched` variable to 0.
|
||||
|
||||
```vim
|
||||
let g:easy_align_ignore_unmatched = 0
|
||||
```
|
||||
|
||||
Or in non-interactive mode, you can provide `ignore_unmatched` option to
|
||||
`:EasyAlign` command as follows.
|
||||
|
||||
```vim
|
||||
:EasyAlign:{'iu':0}
|
||||
```
|
||||
1. Set the global `g:easy_align_ignore_unmatched` variable to 0
|
||||
2. Define a custom alignment rule with `ignore_unmatched` option set to 0
|
||||
3. Provide `ignore_unmatched` option to `:EasyAlign` command. e.g. `:EasyAlign:{'iu':0}`
|
||||
|
||||
Then we get,
|
||||
|
||||
@@ -316,6 +326,159 @@ Then we get,
|
||||
}
|
||||
```
|
||||
|
||||
### Aligning delimiters of different lengths
|
||||
|
||||
Global `g:easy_align_delimiter_align` option and rule-wise/command-wise
|
||||
`delimiter_align` option determines how matched delimiters of different lengths
|
||||
are aligned.
|
||||
|
||||
```ruby
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
```
|
||||
|
||||
By default, delimiters are right-aligned as follows.
|
||||
|
||||
```ruby
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
```
|
||||
|
||||
However, with `:EasyAlign={'da':l}`, delimiters are left-aligned.
|
||||
|
||||
```ruby
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
```
|
||||
|
||||
And on `:EasyAlign={'da':c}`, center-aligned.
|
||||
|
||||
```ruby
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
```
|
||||
|
||||
### Adjusting indentation
|
||||
|
||||
By default :EasyAlign command keeps the original indentation of the lines. But
|
||||
then again we have `indentation` option. See the following example.
|
||||
|
||||
```ruby
|
||||
# Lines with different indentation
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Default: _k_eep the original indentation
|
||||
# :EasyAlign=
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Use the _s_hallowest indentation among the lines
|
||||
# :EasyAlign={'idt':s}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Use the _d_eepest indentation among the lines
|
||||
# :EasyAlign={'idt':d}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Indentation: _n_one
|
||||
# :EasyAlign={'idt':n}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
```
|
||||
|
||||
Notice that `idt` is fuzzy-matched to `indentation`.
|
||||
|
||||
### Left/right/center mode switch in interactive mode
|
||||
|
||||
In interactive mode, you can choose the alignment mode you want by pressing
|
||||
enter keys. The non-bang command, `:EasyAlign` starts in left-alignment mode
|
||||
and changes to right and center mode as you press enter keys, while the bang
|
||||
version first starts in right-alignment mode.
|
||||
|
||||
- `:EasyAlign`
|
||||
- Left, Right, Center
|
||||
- `:EasyAlign!`
|
||||
- Right, Left, Center
|
||||
|
||||
If you do not prefer this default mode transition, you can define your own
|
||||
settings as follows.
|
||||
|
||||
```vim
|
||||
let g:easy_align_interactive_modes = ['l', 'r']
|
||||
let g:easy_align_bang_interactive_modes = ['c', 'r']
|
||||
```
|
||||
|
||||
### Alignments over multiple occurrences of delimiters
|
||||
|
||||
As stated above, "field number" is used to target specific occurrences of
|
||||
the delimiter when it appears multiple times in each line.
|
||||
|
||||
To recap:
|
||||
|
||||
```vim
|
||||
" Left-alignment around the FIRST occurrences of delimiters
|
||||
:EasyAlign =
|
||||
|
||||
" Left-alignment around the SECOND occurrences of delimiters
|
||||
:EasyAlign 2=
|
||||
|
||||
" Left-alignment around the LAST occurrences of delimiters
|
||||
:EasyAlign -=
|
||||
|
||||
" Left-alignment around ALL occurrences of delimiters
|
||||
:EasyAlign *=
|
||||
|
||||
" Left-right ALTERNATING alignment around all occurrences of delimiters
|
||||
:EasyAlign **=
|
||||
|
||||
" Right-left ALTERNATING alignment around all occurrences of delimiters
|
||||
:EasyAlign! **=
|
||||
```
|
||||
|
||||
In addition to these, you can fine-tune alignments over multiple occurrences of
|
||||
the delimiters with 'mode_sequence' option.
|
||||
|
||||
```vim
|
||||
" Left alignment over the first two occurrences of delimiters
|
||||
:EasyAlign = { 'mode_sequence': 'll' }
|
||||
|
||||
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
|
||||
:EasyAlign = { 'm': 'rlc' }
|
||||
|
||||
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
|
||||
:EasyAlign 2={ 'm': 'rlc' }
|
||||
|
||||
" (*) Repeating alignments (default: l, r, or c)
|
||||
" Right, left, center, center, center, center, ...
|
||||
:EasyAlign *={ 'm': 'rlc' }
|
||||
|
||||
" (**) Alternating alignments (default: lr or rl)
|
||||
" Right, left, center, right, left, center, ...
|
||||
:EasyAlign **={ 'm': 'rlc' }
|
||||
```
|
||||
|
||||
### Extending alignment rules
|
||||
|
||||
Although the default rules should cover the most of the use cases,
|
||||
@@ -327,9 +490,9 @@ you can extend the rules by setting a dictionary named `g:easy_align_delimiters`
|
||||
let g:easy_align_delimiters = {
|
||||
\ '>': { 'pattern': '>>\|=>\|>' },
|
||||
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignores': ['String'] },
|
||||
\ '#': { 'pattern': '#\+', 'ignores': ['String'] },
|
||||
\ '#': { 'pattern': '#\+', 'ignores': ['String'], 'delimiter_align': 'l' },
|
||||
\ ']': {
|
||||
\ 'pattern': '[\[\]]',
|
||||
\ 'pattern': '[[\]]',
|
||||
\ 'left_margin': 0,
|
||||
\ 'right_margin': 0,
|
||||
\ 'stick_to_left': 0
|
||||
@@ -339,14 +502,19 @@ let g:easy_align_delimiters = {
|
||||
\ 'left_margin': 0,
|
||||
\ 'right_margin': 0,
|
||||
\ 'stick_to_left': 0
|
||||
\ },
|
||||
\ 'd': {
|
||||
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
|
||||
\ 'left_margin': 0,
|
||||
\ 'right_margin': 0
|
||||
\ }
|
||||
\ }
|
||||
```
|
||||
|
||||
Examples and use cases
|
||||
----------------------
|
||||
Advanced examples and use cases
|
||||
-------------------------------
|
||||
|
||||
See the [link](https://github.com/junegunn/vim-easy-align/blob/master/EXAMPLES.md)
|
||||
See [EXAMPLES.md](https://github.com/junegunn/vim-easy-align/blob/master/EXAMPLES.md)
|
||||
for more examples.
|
||||
|
||||
Author
|
||||
|
||||
@@ -39,12 +39,13 @@ let s:easy_align_delimiters_default = {
|
||||
\ '}': { 'pattern': '}', 'left_margin': ' ', 'right_margin': '', 'stick_to_left': 0 }
|
||||
\ }
|
||||
|
||||
let s:just = ['', '[R]']
|
||||
let s:mode_labels = { 'l': '', 'r': '[R]', 'c': '[C]' }
|
||||
|
||||
let s:known_options = {
|
||||
\ 'margin_left': [0, 1], 'margin_right': [0, 1], 'stick_to_left': [0],
|
||||
\ 'left_margin': [0, 1], 'right_margin': [0, 1],
|
||||
\ 'ignores': [3], 'ignore_unmatched': [0]
|
||||
\ 'margin_left': [0, 1], 'margin_right': [0, 1], 'stick_to_left': [0],
|
||||
\ 'left_margin': [0, 1], 'right_margin': [0, 1], 'indentation': [1],
|
||||
\ 'ignores': [3 ], 'ignore_unmatched': [0 ], 'delimiter_align': [1],
|
||||
\ 'mode_sequence': [1 ]
|
||||
\ }
|
||||
|
||||
if exists("*strwidth")
|
||||
@@ -81,7 +82,7 @@ endfunction
|
||||
|
||||
function! s:echon(l, n, d)
|
||||
echon "\r"
|
||||
echon "\rEasyAlign". s:just[a:l] ." (" .a:n.a:d. ")"
|
||||
echon "\rEasyAlign". s:mode_labels[a:l] ." (" .a:n.a:d. ")"
|
||||
endfunction
|
||||
|
||||
function! s:exit(msg)
|
||||
@@ -97,6 +98,10 @@ function! s:rtrim(str)
|
||||
return substitute(a:str, '\s*$', '', '')
|
||||
endfunction
|
||||
|
||||
function! s:trim(str)
|
||||
return substitute(a:str, '^\s*\(\S*\)\s*$', '\1', '')
|
||||
endfunction
|
||||
|
||||
function! s:fuzzy_lu(key)
|
||||
if has_key(s:known_options, a:key)
|
||||
return a:key
|
||||
@@ -110,10 +115,22 @@ function! s:fuzzy_lu(key)
|
||||
elseif len(matches) == 1
|
||||
return matches[0]
|
||||
else
|
||||
" Avoid ambiguity introduced by deprecated margin_left and margin_right
|
||||
if index(matches, 'mode_sequence') != -1
|
||||
return 'mode_sequence'
|
||||
endif
|
||||
call s:exit("Ambiguous option key: ". a:key ." (" .join(matches, ', '). ")")
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:shift(modes, cycle)
|
||||
let item = remove(a:modes, 0)
|
||||
if a:cycle || empty(a:modes)
|
||||
call add(a:modes, item)
|
||||
endif
|
||||
return item
|
||||
endfunction
|
||||
|
||||
function! s:normalize_options(opts)
|
||||
let ret = {}
|
||||
for k in keys(a:opts)
|
||||
@@ -139,54 +156,121 @@ function! s:validate_options(opts)
|
||||
return a:opts
|
||||
endfunction
|
||||
|
||||
function! s:do_align(just, all_tokens, fl, ll, fc, lc, pattern, nth, ml, mr, stick_to_left, ignore_unmatched, ignores, recursive)
|
||||
let lines = {}
|
||||
let max_just_len = 0
|
||||
let max_delim_len = 0
|
||||
let max_tokens = 0
|
||||
let min_indent = -1
|
||||
let pattern = '\s*\(' .a:pattern. '\)\s' . (a:stick_to_left ? '*' : '\{-}')
|
||||
function! s:split_line(line, nth, modes, cycle, fc, lc, pattern, stick_to_left, ignore_unmatched, ignores)
|
||||
let mode = ''
|
||||
|
||||
let string = a:lc ?
|
||||
\ strpart(getline(a:line), a:fc - 1, a:lc - a:fc + 1) :
|
||||
\ strpart(getline(a:line), a:fc - 1)
|
||||
let idx = 0
|
||||
" Do not allow \zs
|
||||
" 1: whole match
|
||||
" 2: token
|
||||
" 3: delimiter
|
||||
let pattern = '^\(\(.\{-}\s*\)\(' .a:pattern. '\)\s' . (a:stick_to_left ? '*' : '\{-}') . '\)'
|
||||
let tokens = []
|
||||
let delims = []
|
||||
|
||||
" Phase 1: split
|
||||
let ignorable = 0
|
||||
let token = ''
|
||||
while 1
|
||||
let matches = matchlist(string, pattern, idx)
|
||||
" No match
|
||||
if empty(matches) | break | endif
|
||||
|
||||
" Match, but empty delimiter
|
||||
if empty(matches[1])
|
||||
let char = strpart(string, idx, 1)
|
||||
if empty(char) | break | endif
|
||||
let [match, part, delim] = [char, char, '']
|
||||
" Match
|
||||
else
|
||||
let [match, part, delim] = matches[1 : 3]
|
||||
endif
|
||||
|
||||
let ignorable = s:highlighted_as(a:line, idx + len(part) + a:fc, a:ignores)
|
||||
if ignorable
|
||||
let token .= match
|
||||
else
|
||||
let [pmode, mode] = [mode, s:shift(a:modes, a:cycle)]
|
||||
call add(tokens, token . match)
|
||||
call add(delims, delim)
|
||||
let token = ''
|
||||
endif
|
||||
|
||||
let idx += len(match)
|
||||
|
||||
" If the string is non-empty and ends with the delimiter,
|
||||
" append an empty token to the list
|
||||
if idx == len(string)
|
||||
call add(tokens, '')
|
||||
call add(delims, '')
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
|
||||
let leftover = token . strpart(string, idx)
|
||||
if !empty(leftover)
|
||||
let ignorable = s:highlighted_as(a:line, len(string) + a:fc - 1, a:ignores)
|
||||
call add(tokens, leftover)
|
||||
call add(delims, '')
|
||||
endif
|
||||
let [pmode, mode] = [mode, s:shift(a:modes, a:cycle)]
|
||||
|
||||
" Preserve indentation - merge first two tokens
|
||||
if len(tokens) > 1 && empty(s:rtrim(tokens[0]))
|
||||
let tokens[1] = tokens[0] . tokens[1]
|
||||
call remove(tokens, 0)
|
||||
call remove(delims, 0)
|
||||
let mode = pmode
|
||||
endif
|
||||
|
||||
" Skip comment line
|
||||
if ignorable && len(tokens) == 1 && a:ignore_unmatched
|
||||
let tokens = []
|
||||
let delims = []
|
||||
" Append an empty item to enable right/center alignment of the last token
|
||||
" - if the last token is not ignorable or ignorable but not the only token
|
||||
elseif (mode == 'r' || mode == 'c') && (!ignorable || len(tokens) > 1) && a:nth >= 0 " includes -0
|
||||
call add(tokens, '')
|
||||
call add(delims, '')
|
||||
endif
|
||||
|
||||
return [tokens, delims]
|
||||
endfunction
|
||||
|
||||
function! s:max(old, new)
|
||||
for k in keys(a:new)
|
||||
if a:new[k] > a:old[k]
|
||||
let a:old[k] = a:new[k] " max() doesn't work with Floats
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:do_align(modes, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth,
|
||||
\ ml, mr, da, indentation, stick_to_left, ignore_unmatched, ignores, recur)
|
||||
let mode = a:modes[0]
|
||||
let lines = {}
|
||||
let min_indent = -1
|
||||
let max = { 'pivot_len': 0.0, 'token_len': 0, 'just_len': 0, 'delim_len': 0,
|
||||
\ 'indent': 0, 'tokens': 0 }
|
||||
|
||||
" Phase 1
|
||||
for line in range(a:fl, a:ll)
|
||||
if !has_key(a:all_tokens, line)
|
||||
" Split line into the tokens by the delimiters
|
||||
let raw_tokens = split(a:lc ?
|
||||
\ strpart(getline(line), a:fc - 1, a:lc - a:fc + 1) :
|
||||
\ strpart(getline(line), a:fc - 1),
|
||||
\ pattern.'\zs')
|
||||
let concat = 0
|
||||
if empty(a:ignores)
|
||||
let tokens = raw_tokens
|
||||
else
|
||||
" Concat adjacent tokens that are split by ignorable delimiters
|
||||
let tokens = []
|
||||
let idx = 0
|
||||
for token in raw_tokens
|
||||
let idx += len(token)
|
||||
if concat
|
||||
let tokens[len(tokens) - 1] .= token
|
||||
else
|
||||
call add(tokens, token)
|
||||
endif
|
||||
let concat = s:highlighted_as(line, idx + a:fc - 1, a:ignores)
|
||||
endfor
|
||||
endif
|
||||
|
||||
" Preserve indentation - merge first two tokens
|
||||
if !empty(tokens) && match(tokens[0], '^\s*$') != -1
|
||||
let tokens = extend([join(tokens[0:1], '')], tokens[2:-1])
|
||||
endif
|
||||
|
||||
" Skip comment line
|
||||
if concat && len(tokens) == 1 && a:ignore_unmatched
|
||||
let tokens = []
|
||||
endif
|
||||
let [tokens, delims] = s:split_line(
|
||||
\ line, a:nth, copy(a:modes), a:recur == 2,
|
||||
\ a:fc, a:lc, a:pattern,
|
||||
\ a:stick_to_left, a:ignore_unmatched, a:ignores)
|
||||
|
||||
" Remember tokens for subsequent recursive calls
|
||||
let a:all_tokens[line] = tokens
|
||||
let a:all_delims[line] = delims
|
||||
else
|
||||
let tokens = a:all_tokens[line]
|
||||
let delims = a:all_delims[line]
|
||||
endif
|
||||
|
||||
" Skip empty lines
|
||||
@@ -195,16 +279,20 @@ function! s:do_align(just, all_tokens, fl, ll, fc, lc, pattern, nth, ml, mr, sti
|
||||
endif
|
||||
|
||||
" Calculate the maximum number of tokens for a line within the range
|
||||
let max_tokens = max([len(tokens), max_tokens])
|
||||
call s:max(max, { 'tokens': len(tokens) })
|
||||
|
||||
if a:nth > 0 " Positive field number
|
||||
if len(tokens) < a:nth
|
||||
continue
|
||||
endif
|
||||
let nth = a:nth - 1 " make it 0-based
|
||||
else " Negative field number
|
||||
let nth = len(tokens) + a:nth
|
||||
if match(tokens[len(tokens) - 1], pattern.'$') == -1
|
||||
else " -0 or Negative field number
|
||||
if a:nth == 0 && mode != 'l'
|
||||
let nth = len(tokens) - 1
|
||||
else
|
||||
let nth = len(tokens) + a:nth
|
||||
endif
|
||||
if empty(delims[len(delims) - 1])
|
||||
let nth -= 1
|
||||
endif
|
||||
|
||||
@@ -213,12 +301,11 @@ function! s:do_align(just, all_tokens, fl, ll, fc, lc, pattern, nth, ml, mr, sti
|
||||
endif
|
||||
endif
|
||||
|
||||
let last = tokens[nth]
|
||||
let prefix = (nth > 0 ? join(tokens[0 : nth - 1], '') : '')
|
||||
let token = substitute(last, pattern.'$', '', '')
|
||||
|
||||
let delim = get(matchlist(last, pattern.'$'), 1, '')
|
||||
if empty(delim) && a:just == 0 && a:ignore_unmatched
|
||||
let prefix = nth > 0 ? join(tokens[0 : nth - 1], '') : ''
|
||||
let delim = delims[nth]
|
||||
let token = s:rtrim( tokens[nth] )
|
||||
let token = s:rtrim( strpart(token, 0, len(token) - len(s:rtrim(delim))) )
|
||||
if empty(delim) && !exists('tokens[nth + 1]') && a:ignore_unmatched
|
||||
continue
|
||||
endif
|
||||
|
||||
@@ -226,14 +313,46 @@ function! s:do_align(just, all_tokens, fl, ll, fc, lc, pattern, nth, ml, mr, sti
|
||||
if min_indent < 0 || indent < min_indent
|
||||
let min_indent = indent
|
||||
endif
|
||||
let max_just_len = max([s:strwidth(prefix.token), max_just_len])
|
||||
let max_delim_len = max([s:strwidth(delim), max_delim_len])
|
||||
let [pw, tw] = [s:strwidth(prefix), s:strwidth(token)]
|
||||
call s:max(max, { 'indent': indent, 'token_len': tw, 'just_len': pw + tw,
|
||||
\ 'delim_len': s:strwidth(delim), 'pivot_len': pw + tw / 2.0 })
|
||||
let lines[line] = [nth, prefix, token, delim]
|
||||
endfor
|
||||
|
||||
" Phase 1-5: indentation handling (only on a:nth == 1)
|
||||
if a:nth == 1
|
||||
if a:indentation ==? 'd'
|
||||
let indent = repeat(' ', max.indent)
|
||||
elseif a:indentation ==? 's'
|
||||
let indent = repeat(' ', min_indent)
|
||||
elseif a:indentation ==? 'n'
|
||||
let indent = ''
|
||||
elseif a:indentation !=? 'k'
|
||||
call s:exit('Invalid indentation: ' . a:indentation)
|
||||
end
|
||||
|
||||
if a:indentation !=? 'k'
|
||||
let max.just_len = 0
|
||||
let max.token_len = 0
|
||||
let max.pivot_len = 0
|
||||
|
||||
for [line, elems] in items(lines)
|
||||
let [nth, prefix, token, delim] = elems
|
||||
|
||||
let token = substitute(token, '^\s*', indent, '')
|
||||
let [pw, tw] = [s:strwidth(prefix), s:strwidth(token)]
|
||||
call s:max(max,
|
||||
\ { 'token_len': tw, 'just_len': pw + tw, 'pivot_len': pw + tw / 2.0 })
|
||||
|
||||
let lines[line][2] = token
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
|
||||
" Phase 2
|
||||
for [line, elems] in items(lines)
|
||||
let tokens = a:all_tokens[line]
|
||||
let delims = a:all_delims[line]
|
||||
let [nth, prefix, token, delim] = elems
|
||||
|
||||
" Remove the leading whitespaces of the next token
|
||||
@@ -242,25 +361,40 @@ function! s:do_align(just, all_tokens, fl, ll, fc, lc, pattern, nth, ml, mr, sti
|
||||
endif
|
||||
|
||||
" Pad the token with spaces
|
||||
let pad = repeat(' ', max_just_len - s:strwidth(prefix) - s:strwidth(token))
|
||||
let [pw, tw] = [s:strwidth(prefix), s:strwidth(token)]
|
||||
let rpad = ''
|
||||
if a:just == 0
|
||||
if mode == 'l'
|
||||
let pad = repeat(' ', max.just_len - pw - tw)
|
||||
if a:stick_to_left
|
||||
let rpad = pad
|
||||
else
|
||||
let token = token . pad
|
||||
endif
|
||||
elseif a:just == 1
|
||||
elseif mode == 'r'
|
||||
let pad = repeat(' ', max.just_len - pw - tw)
|
||||
let token = pad . token
|
||||
elseif mode == 'c'
|
||||
let p1 = max.pivot_len - (pw + tw / 2.0)
|
||||
let p2 = (max.token_len - tw) / 2.0
|
||||
let pf1 = floor(p1)
|
||||
if pf1 < p1 | let p2 = ceil(p2)
|
||||
else | let p2 = floor(p2)
|
||||
endif
|
||||
let token = repeat(' ', float2nr(pf1)) .token. repeat(' ', float2nr(p2))
|
||||
endif
|
||||
let tokens[nth] = token
|
||||
|
||||
" Pad the delimiter
|
||||
let dpad = repeat(' ', max_delim_len - s:strwidth(delim))
|
||||
if a:stick_to_left
|
||||
let rpad = rpad . dpad
|
||||
let dpadl = max.delim_len - s:strwidth(delim)
|
||||
if a:da ==? 'l'
|
||||
let [dl, dr] = ['', repeat(' ', dpadl)]
|
||||
elseif a:da ==? 'c'
|
||||
let dl = repeat(' ', dpadl / 2)
|
||||
let dr = repeat(' ', dpadl - dpadl / 2)
|
||||
elseif a:da ==? 'r'
|
||||
let [dl, dr] = [repeat(' ', dpadl), '']
|
||||
else
|
||||
let delim = dpad . delim
|
||||
call s:exit('Invalid delimiter_align: ' . a:da)
|
||||
endif
|
||||
|
||||
" Before and after the range (for blockwise visual mode)
|
||||
@@ -277,8 +411,8 @@ function! s:do_align(just, all_tokens, fl, ll, fc, lc, pattern, nth, ml, mr, sti
|
||||
" Adjust indentation of the lines starting with a delimiter
|
||||
let lpad = ''
|
||||
if nth == 0
|
||||
let ipad = repeat(' ', min_indent - len(strpart(before.token, '^\s\+').ml))
|
||||
if a:just == 0
|
||||
let ipad = repeat(' ', min_indent - len(token.ml))
|
||||
if mode == 'l'
|
||||
let token = ipad . token
|
||||
else
|
||||
let lpad = ipad
|
||||
@@ -286,7 +420,7 @@ function! s:do_align(just, all_tokens, fl, ll, fc, lc, pattern, nth, ml, mr, sti
|
||||
endif
|
||||
|
||||
" Align the token
|
||||
let aligned = join([lpad, token, ml, delim, mr, rpad], '')
|
||||
let aligned = join([lpad, token, ml, dl, delim, dr, mr, rpad], '')
|
||||
let tokens[nth] = aligned
|
||||
|
||||
" Update the line
|
||||
@@ -294,32 +428,34 @@ function! s:do_align(just, all_tokens, fl, ll, fc, lc, pattern, nth, ml, mr, sti
|
||||
call setline(line, newline)
|
||||
endfor
|
||||
|
||||
if a:recursive && a:nth < max_tokens
|
||||
let just = a:recursive == 2 ? !a:just : a:just
|
||||
call s:do_align(just, a:all_tokens, a:fl, a:ll, a:fc, a:lc, a:pattern,
|
||||
\ a:nth + 1, a:ml, a:mr, a:stick_to_left, a:ignore_unmatched,
|
||||
\ a:ignores, a:recursive)
|
||||
if a:nth < max.tokens && (a:recur || len(a:modes) > 1)
|
||||
call s:shift(a:modes, a:recur == 2)
|
||||
call s:do_align(
|
||||
\ a:modes, a:all_tokens, a:all_delims,
|
||||
\ a:fl, a:ll, a:fc, a:lc, a:pattern,
|
||||
\ a:nth + 1, a:ml, a:mr, a:da, a:indentation, a:stick_to_left,
|
||||
\ a:ignore_unmatched, a:ignores, a:recur)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:interactive(just)
|
||||
let just = a:just
|
||||
function! s:interactive(modes)
|
||||
let mode = s:shift(a:modes, 1)
|
||||
let n = ''
|
||||
let ch = ''
|
||||
|
||||
while 1
|
||||
call s:echon(just, n, '')
|
||||
call s:echon(mode, n, '')
|
||||
|
||||
let c = getchar()
|
||||
let ch = nr2char(c)
|
||||
if c == 3 || c == 27 " CTRL-C / ESC
|
||||
throw 'exit'
|
||||
elseif c == '<27>kb' " Backspace
|
||||
elseif c == "\<bs>"
|
||||
if len(n) > 0
|
||||
let n = strpart(n, 0, len(n) - 1)
|
||||
endif
|
||||
elseif c == 13 " Enter key
|
||||
let just = (just + 1) % len(s:just)
|
||||
let mode = s:shift(a:modes, 1)
|
||||
elseif ch == '-'
|
||||
if empty(n) | let n = '-'
|
||||
elseif n == '-' | let n = ''
|
||||
@@ -339,7 +475,7 @@ function! s:interactive(just)
|
||||
break
|
||||
endif
|
||||
endwhile
|
||||
return [just, n, ch]
|
||||
return [mode, n, ch]
|
||||
endfunction
|
||||
|
||||
function! s:parse_args(args)
|
||||
@@ -352,14 +488,19 @@ function! s:parse_args(args)
|
||||
" Poor man's option parser
|
||||
let idx = 0
|
||||
while 1
|
||||
let midx = match(args, '{.*}\s*$', idx)
|
||||
let midx = match(args, '\s*{.*}\s*$', idx)
|
||||
if midx == -1 | break | endif
|
||||
|
||||
let cand = strpart(args, midx)
|
||||
try
|
||||
let [l, r, c, k, s, d, n] = ['l', 'r', 'c', 'k', 's', 'd', 'n']
|
||||
let [L, R, C, K, S, D, N] = ['l', 'r', 'c', 'k', 's', 'd', 'n']
|
||||
let o = eval(cand)
|
||||
if type(o) == 4
|
||||
let option = o
|
||||
if args[midx - 1 : midx] == '\ '
|
||||
let midx += 1
|
||||
endif
|
||||
let args = strpart(args, 0, midx)
|
||||
break
|
||||
endif
|
||||
@@ -384,10 +525,6 @@ function! s:parse_args(args)
|
||||
try | call matchlist('', regexp)
|
||||
catch | call s:exit("Invalid regular expression: ". regexp)
|
||||
endtry
|
||||
" Unsupported regular expression
|
||||
if match(regexp, '\\zs') != -1
|
||||
call s:exit("Using \\zs is not allowed. Use stick_to_left option instead.")
|
||||
endif
|
||||
return [matches[1], regexp, option, 1]
|
||||
else
|
||||
let tokens = matchlist(args, '^\([1-9][0-9]*\|-[0-9]*\|\*\*\?\)\?\s*\(.\{-}\)\?$')
|
||||
@@ -395,8 +532,11 @@ function! s:parse_args(args)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! easy_align#align(just, expr) range
|
||||
let just = a:just
|
||||
function! easy_align#align(bang, expr) range
|
||||
let modes = get(g:,
|
||||
\ (a:bang ? 'easy_align_bang_interactive_modes' : 'easy_align_interactive_modes'),
|
||||
\ (a:bang ? ['r', 'l', 'c'] : ['l', 'r', 'c']))
|
||||
let mode = modes[0]
|
||||
let recur = 0
|
||||
let n = ''
|
||||
let ch = ''
|
||||
@@ -405,10 +545,12 @@ function! easy_align#align(just, expr) range
|
||||
|
||||
try
|
||||
if empty(a:expr)
|
||||
let [just, n, ch] = s:interactive(just)
|
||||
let [mode, n, ch] = s:interactive(copy(modes))
|
||||
else
|
||||
let [n, ch, option, regexp] = s:parse_args(a:expr)
|
||||
if empty(ch)
|
||||
if empty(n) && empty(ch)
|
||||
let [mode, n, ch] = s:interactive(copy(modes))
|
||||
elseif empty(ch)
|
||||
" Try swapping n and ch
|
||||
let [n, ch] = ['', n]
|
||||
endif
|
||||
@@ -436,10 +578,15 @@ function! easy_align#align(just, expr) range
|
||||
if regexp
|
||||
let dict = { 'pattern': ch }
|
||||
else
|
||||
if ch =~ '^\\\s\+$'
|
||||
let ch = ' '
|
||||
elseif ch =~ '^\\\\\s\+$'
|
||||
let ch = '\'
|
||||
" Resolving command-line ambiguity
|
||||
if !empty(a:expr)
|
||||
" '\ ' => ' '
|
||||
if ch =~ '^\\\s\+$'
|
||||
let ch = ' '
|
||||
" '\\' => '\'
|
||||
elseif ch =~ '^\\\\\s*$'
|
||||
let ch = '\'
|
||||
endif
|
||||
endif
|
||||
if !has_key(delimiters, ch)
|
||||
echon "\rUnknown delimiter key: ". ch
|
||||
@@ -461,17 +608,34 @@ function! easy_align#align(just, expr) range
|
||||
if type(ml) == 0 | let ml = repeat(' ', ml) | endif
|
||||
if type(mr) == 0 | let mr = repeat(' ', mr) | endif
|
||||
|
||||
call s:do_align(just, {}, a:firstline, a:lastline,
|
||||
\ visualmode() == '' ? min([col("'<"), col("'>")]) : 1,
|
||||
\ visualmode() == '' ? max([col("'<"), col("'>")]) : 0,
|
||||
let bvisual = char2nr(visualmode()) == 22 " ^V
|
||||
|
||||
if recur && bvisual
|
||||
echon "\rRecursive alignment is currently not supported in blockwise-visual mode"
|
||||
return
|
||||
endif
|
||||
|
||||
let aseq = get(dict, 'mode_sequence',
|
||||
\ recur == 2 ? (mode == 'r' ? ['r', 'l'] : ['l', 'r']) : [mode])
|
||||
|
||||
try
|
||||
call s:do_align(
|
||||
\ type(aseq) == 1 ? split(tolower(aseq), '\s*') : map(copy(aseq), 'tolower(v:val)'),
|
||||
\ {}, {}, a:firstline, a:lastline,
|
||||
\ bvisual ? min([col("'<"), col("'>")]) : 1,
|
||||
\ bvisual ? max([col("'<"), col("'>")]) : 0,
|
||||
\ get(dict, 'pattern', ch),
|
||||
\ nth,
|
||||
\ ml,
|
||||
\ mr,
|
||||
\ get(dict, 'delimiter_align', get(g:, 'easy_align_delimiter_align', 'r')),
|
||||
\ get(dict, 'indentation', get(g:, 'easy_align_indentation', 'k')),
|
||||
\ get(dict, 'stick_to_left', 0),
|
||||
\ get(dict, 'ignore_unmatched', get(g:, 'easy_align_ignore_unmatched', 1)),
|
||||
\ get(dict, 'ignores', s:ignored_syntax()),
|
||||
\ recur)
|
||||
call s:echon(just, n, regexp ? '/'.ch.'/' : ch)
|
||||
call s:echon(mode, n, regexp ? '/'.ch.'/' : ch)
|
||||
catch 'exit'
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
*easy_align.txt* A simple, easy-to-use Vim alignment plugin
|
||||
|
||||
vim-easy-align *vim-easy-align* *easy-align*
|
||||
=========================================================================
|
||||
|
||||
A simple, easy-to-use Vim alignment plugin without too much ambition.
|
||||
A simple, easy-to-use Vim alignment plugin.
|
||||
|
||||
Author: Junegunn Choi
|
||||
Source: https://github.com/junegunn/vim-easy-align
|
||||
Author: Junegunn Choi
|
||||
Source: https://github.com/junegunn/vim-easy-align
|
||||
License: MIT
|
||||
|
||||
|
||||
EasyAlign *:EasyAlign* *:EasyAlign!*
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
vim-easy-align defines `:EasyAlign` command in the visual mode.
|
||||
(:EasyAlign! is the right-justification version.)
|
||||
(:EasyAlign! is the right-align version.)
|
||||
|
||||
| Mode | Command |
|
||||
| ------------------------- | ------------------------------------------- |
|
||||
| Interactive mode | :EasyAlign |
|
||||
| Using predefined rules | :EasyAlign [FIELD#] DELIMITER_KEY [OPTIONS] |
|
||||
| Using regular expressions | :EasyAlign [FIELD#] /REGEXP/ [OPTIONS] |
|
||||
| Mode | Command |
|
||||
| ------------------------- | ---------------------------------------------- |
|
||||
| Interactive mode | :EasyAlign[!] [OPTIONS] |
|
||||
| Using predefined rules | :EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS] |
|
||||
| Using regular expressions | :EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS] |
|
||||
|
||||
|
||||
Interactive mode
|
||||
@@ -32,16 +35,16 @@ your `.vimrc`.
|
||||
With this mapping, you can align selected lines of text with a few keystrokes.
|
||||
|
||||
1. <Enter> key to start interactive EasyAlign command
|
||||
2. Optional Enter keys to switch justficiation mode (default: left)
|
||||
2. Optional Enter keys to select alignment mode (left, right, or center)
|
||||
3. Optional field number (default: 1)
|
||||
1 Around the 1st occurrences of delimiters
|
||||
2 Around the 2nd occurrences of delimiters
|
||||
* Around all occurrences of delimiters
|
||||
** Left-right alternating alignment around all delimiters
|
||||
- Around the last occurrences of delimiters (`-1`)
|
||||
- Around the last occurrences of delimiters (-1)
|
||||
-2 Around the second to last occurrences of delimiters
|
||||
...
|
||||
4. Delimiter key (a single keystroke)
|
||||
4. Delimiter key for the predefined rules (a single keystroke)
|
||||
<space> General alignment around whitespaces
|
||||
= Operators containing equals sign (=, ==, !=, +=, &&=, ...)
|
||||
: Suitable for formatting JSON or YAML
|
||||
@@ -49,7 +52,10 @@ With this mapping, you can align selected lines of text with a few keystrokes.
|
||||
, Multi-line method arguments. CSV.
|
||||
| Table markdown
|
||||
|
||||
During the key sequence, <Enter> key will toggle right-justification mode.
|
||||
(You can override these default rules or define your own rules with
|
||||
`g:easy_align_delimiters`, which will be described in the later section.)
|
||||
|
||||
During the key sequence, <Enter> key will toggle right-align mode.
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -62,7 +68,7 @@ Examples:
|
||||
<Enter>3= Alignment around 3rd equals signs (and the likes)
|
||||
<Enter>*= Alignment around all equals signs (and the likes)
|
||||
<Enter>**= Left-right alternating alignment around all equals signs
|
||||
<Enter><Enter>= Right-justified alignment around 1st equals signs
|
||||
<Enter><Enter>= Right-alignment around 1st equals signs
|
||||
<Enter><Enter>**= Right-left alternating alignment around all equals signs
|
||||
|
||||
|
||||
@@ -91,7 +97,7 @@ try these commands:
|
||||
- :EasyAlign */[:;]\+/
|
||||
- :EasyAlign **/[:;]\+/
|
||||
|
||||
Notice that you can't append `\zs` to your regular expression to put delimiters
|
||||
Notice that you can't append '\zs' to your regular expression to put delimiters
|
||||
on the left. It can be done by providing additional options in Vim dictionary
|
||||
format.
|
||||
|
||||
@@ -102,7 +108,7 @@ Then we get:
|
||||
apple;: banana:: cake
|
||||
data;; exchange:; format
|
||||
|
||||
Options keys are fuzzy-matched, so you can write as follows:
|
||||
Option names are fuzzy-matched, so you can write as follows:
|
||||
|
||||
- :EasyAlign * /[:;]\+/ { 'stl': 1, 'l': '' }
|
||||
|
||||
@@ -112,19 +118,25 @@ You can even omit spaces between the arguments, so concisely (or cryptically):
|
||||
|
||||
Available options are as follows.
|
||||
|
||||
| Atrribute | Type | Default |
|
||||
| ---------------- | ---------------- | ----------------------- |
|
||||
| left_margin | number or string | 0 |
|
||||
| right_margin | number or string | 0 |
|
||||
| stick_to_left | boolean | 0 |
|
||||
| ignore_unmatched | boolean | 1 |
|
||||
| ignores | array | `['String', 'Comment']` |
|
||||
| Atrribute | Type | Default |
|
||||
| ---------------- | ---------------- | ----------------------------- |
|
||||
| left_margin | number or string | 0 |
|
||||
| right_margin | number or string | 0 |
|
||||
| stick_to_left | boolean | 0 |
|
||||
| ignore_unmatched | boolean | 1 |
|
||||
| ignores | array | ['String', 'Comment'] |
|
||||
| delimiter_align | string | 'r' |
|
||||
| | | (right, left, center) |
|
||||
| indentation | string | 'k' |
|
||||
| | | (keep, shallow, deep, none) |
|
||||
| mode_sequence | string | (Depends on field number and |
|
||||
| | | selected alignment mode) |
|
||||
|
||||
|
||||
Partial alignment in blockwise-visual mode
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
In blockwise-visual mode (`CTRL-V`), EasyAlign command aligns only
|
||||
In blockwise-visual mode (CTRL-V), EasyAlign command aligns only
|
||||
the selected text in the block, instead of the whole lines in the range.
|
||||
|
||||
|
||||
@@ -151,7 +163,7 @@ For example, the following paragraph
|
||||
'grape:fruits': 3
|
||||
}
|
||||
|
||||
becomes as follows on `<Enter>:`
|
||||
becomes as follows on '<Enter>:' (or `:EasyAlign:`)
|
||||
|
||||
{
|
||||
# Quantity of apples: 1
|
||||
@@ -164,17 +176,13 @@ becomes as follows on `<Enter>:`
|
||||
|
||||
Naturally, this feature only works when syntax highlighting is enabled.
|
||||
|
||||
You can change the default rule by either defining global `g:easy_align_ignores`
|
||||
array,
|
||||
You can change the default rule by using one of these 3 methods.
|
||||
|
||||
" Ignore nothing!
|
||||
let g:easy_align_ignores = []
|
||||
1. Define global `g:easy_align_ignores` list
|
||||
2. Define a custom rule in `g:easy_align_delimiters` with 'ignores' option
|
||||
3. Provide 'ignores' option to `:EasyAlign` command. e.g. :EasyAlign:{'is':[]}
|
||||
|
||||
or providing `ignores` option directly to :EasyAlign command
|
||||
|
||||
:EasyAlign:{'is':[]}
|
||||
|
||||
Then you get,
|
||||
For example if you set 'ignores' option to be an empty list, you get
|
||||
|
||||
{
|
||||
# Quantity of apples: 1
|
||||
@@ -190,7 +198,7 @@ Ignoring unmatched lines *g:easy_align_ignore_unmatched*
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
Lines without any matching delimiter are ignored as well (except in
|
||||
right-justification mode).
|
||||
right-align mode).
|
||||
|
||||
For example, when aligning the following code block around the colons,
|
||||
|
||||
@@ -212,17 +220,13 @@ this is usually what we want.
|
||||
grapefruits: 3
|
||||
}
|
||||
|
||||
However, this default behavior is also configurable.
|
||||
|
||||
One way is to set the global `g:easy_align_ignore_unmatched` variable to 0.
|
||||
|
||||
let g:easy_align_ignore_unmatched = 0
|
||||
|
||||
Or in non-interactive mode, you can provide `ignore_unmatched` option to
|
||||
`:EasyAlign` command as follows.
|
||||
|
||||
:EasyAlign:{'iu':0}
|
||||
However, this default behavior is also configurable by using one of these 3
|
||||
methods.
|
||||
|
||||
1. Set the global `g:easy_align_ignore_unmatched` variable to 0
|
||||
2. Define a custom alignment rule with 'ignore_unmatched' option set to 0
|
||||
3. Provide 'ignore_unmatched' option to `:EasyAlign` command.
|
||||
e.g. :EasyAlign:{'iu':0}
|
||||
|
||||
Then we get,
|
||||
|
||||
@@ -235,6 +239,154 @@ Then we get,
|
||||
}
|
||||
|
||||
|
||||
Aligning delimiters of different lengths *g:easy_align_delimiter_align*
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
Global `g:easy_align_delimiter_align` option and rule-wise/command-wise
|
||||
'delimiter_align' option determines how matched delimiters of different
|
||||
lengths are aligned.
|
||||
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
|
||||
By default, delimiters are right-aligned as follows.
|
||||
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
|
||||
However, with ':EasyAlign={'da':l}', delimiters are left-aligned.
|
||||
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
|
||||
And on ':EasyAlign={'da':c}', center-aligned.
|
||||
|
||||
apple = 1
|
||||
banana += apple
|
||||
cake ||= banana
|
||||
|
||||
|
||||
Adjusting indentation *g:easy_align_indentation*
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
By default :EasyAlign command keeps the original indentation of the lines.
|
||||
But then again we have 'indentation' option. See the following example.
|
||||
|
||||
# Lines with different indentation
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Default: _k_eep the original indentation
|
||||
# :EasyAlign=
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Use the _s_hallowest indentation among the lines
|
||||
# :EasyAlign={'idt':s}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Use the _d_eepest indentation among the lines
|
||||
# :EasyAlign={'idt':d}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
# Indentation: _n_one
|
||||
# :EasyAlign={'idt':n}
|
||||
apple = 1
|
||||
banana = 2
|
||||
cake = 3
|
||||
daisy = 4
|
||||
eggplant = 5
|
||||
|
||||
|
||||
Notice that 'idt' is fuzzy-matched to 'indentation'.
|
||||
|
||||
|
||||
Left/right/center mode switch in interactive mode
|
||||
-------------------------------------------------------------------------
|
||||
*g:easy_align_interactive_modes*
|
||||
*g:easy_align_bang_interactive_modes*
|
||||
|
||||
In interactive mode, you can choose the alignment mode you want by pressing
|
||||
enter keys. The non-bang command, `:EasyAlign` starts in left-alignment mode
|
||||
and changes to right and center mode as you press enter keys, while the bang
|
||||
version first starts in right-alignment mode.
|
||||
|
||||
- `:EasyAlign`
|
||||
- Left, Right, Center
|
||||
- `:EasyAlign!`
|
||||
- Right, Left, Center
|
||||
|
||||
If you do not prefer this default mode transition, you can define your own
|
||||
settings as follows.
|
||||
|
||||
let g:easy_align_interactive_modes = ['l', 'r']
|
||||
let g:easy_align_bang_interactive_modes = ['c', 'r']
|
||||
|
||||
|
||||
Alignments over multiple occurrences of delimiters
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
As stated above, "field number" is used to target specific occurrences of
|
||||
the delimiter when it appears multiple times in each line.
|
||||
|
||||
To recap:
|
||||
|
||||
" Left-alignment around the FIRST occurrences of delimiters
|
||||
:EasyAlign =
|
||||
|
||||
" Left-alignment around the SECOND occurrences of delimiters
|
||||
:EasyAlign 2=
|
||||
|
||||
" Left-alignment around the LAST occurrences of delimiters
|
||||
:EasyAlign -=
|
||||
|
||||
" Left-alignment around ALL occurrences of delimiters
|
||||
:EasyAlign *=
|
||||
|
||||
" Left-right ALTERNATING alignment around all occurrences of delimiters
|
||||
:EasyAlign **=
|
||||
|
||||
" Right-left ALTERNATING alignment around all occurrences of delimiters
|
||||
:EasyAlign! **=
|
||||
|
||||
In addition to these, you can fine-tune alignments over multiple occurrences of
|
||||
the delimiters with 'mode_sequence' option.
|
||||
|
||||
" Left alignment over the first two occurrences of delimiters
|
||||
:EasyAlign = { 'mode_sequence': 'll' }
|
||||
|
||||
" Right, left, center alignment over the 1st to 3rd occurrences of delimiters
|
||||
:EasyAlign = { 'm': 'rlc' }
|
||||
|
||||
" Right, left, center alignment over the 2nd to 4th occurrences of delimiters
|
||||
:EasyAlign 2={ 'm': 'rlc' }
|
||||
|
||||
" (*) Repeating alignments (default: l, r, or c)
|
||||
" Right, left, center, center, center, center, ...
|
||||
:EasyAlign *={ 'm': 'rlc' }
|
||||
|
||||
" (**) Alternating alignments (default: lr or rl)
|
||||
" Right, left, center, right, left, center, ...
|
||||
:EasyAlign **={ 'm': 'rlc' }
|
||||
|
||||
|
||||
Extending alignment rules *g:easy_align_delimiters*
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
@@ -247,7 +399,7 @@ you can extend the rules by setting a dictionary named
|
||||
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignores': ['String'] },
|
||||
\ '#': { 'pattern': '#\+', 'ignores': ['String'] },
|
||||
\ ']': {
|
||||
\ 'pattern': '[\[\]]',
|
||||
\ 'pattern': '[[\]]',
|
||||
\ 'left_margin': 0,
|
||||
\ 'right_margin': 0,
|
||||
\ 'stick_to_left': 0
|
||||
|
||||
@@ -109,10 +109,10 @@ j, , k
|
||||
bbbb = 2
|
||||
ccccccc = 3
|
||||
ccccccccccccccc
|
||||
ddd = 4
|
||||
ddd = #
|
||||
eeee === eee = eee = eee=f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == 888
|
||||
g != hhhhhhhh == # 8
|
||||
i := 5
|
||||
i %= 5
|
||||
i *= 5
|
||||
@@ -134,10 +134,10 @@ a = 1
|
||||
bbbb = 2
|
||||
ccccccc = 3
|
||||
ccccccccccccccc
|
||||
ddd = 4
|
||||
ddd = #
|
||||
eeee === eee = eee = eee = f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == 888
|
||||
g != hhhhhhhh == # 8
|
||||
i := 5
|
||||
i %= 5
|
||||
i *= 5
|
||||
@@ -159,10 +159,10 @@ a = 1
|
||||
bbbb = 2
|
||||
ccccccc = 3
|
||||
ccccccccccccccc
|
||||
ddd = 4
|
||||
ddd = #
|
||||
eeee === eee = eee = eee = f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == 888
|
||||
g != hhhhhhhh == # 8
|
||||
i := 5
|
||||
i %= 5
|
||||
i *= 5
|
||||
@@ -184,10 +184,10 @@ a = 1
|
||||
bbbb = 2
|
||||
ccccccc = 3
|
||||
ccccccccccccccc
|
||||
ddd = 4
|
||||
ddd = #
|
||||
eeee === eee = eee = eee=f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == 888
|
||||
g != hhhhhhhh == # 8
|
||||
i := 5
|
||||
i %= 5
|
||||
i *= 5
|
||||
@@ -233,6 +233,14 @@ 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
|
||||
@@ -336,6 +344,7 @@ my_object .
|
||||
| batch_size | Fixnum | nil | number of maximum items to be assigned at once |
|
||||
| logger | Logger | nil | logger instance for debug logs |
|
||||
|
||||
|
||||
|Option |Type |Default |Description |
|
||||
|-- |-- |-- |-- |
|
||||
|threads |Fixnum |1 |number of threads in the thread pool |
|
||||
@@ -346,13 +355,569 @@ my_object .
|
||||
|batch_size |Fixnum |nil |number of maximum items to be assigned at once |
|
||||
|logger |Logger |nil |logger instance for debug logs |
|
||||
|
||||
| Option <| Type <| Default<| Description <|
|
||||
| -- <| -- <| -- <| -- <|
|
||||
| threads <| Fixnum <| 1 <| number of threads in the thread pool <|
|
||||
| queues <| Fixnum <| 1 <| number of concurrent queues <|
|
||||
| queue_size<| Fixnum <| 1000 <| size of each queue <|
|
||||
| interval <| Numeric<| 0 <| dispatcher interval for batch processing <|
|
||||
| batch <| Boolean<| false <| enables batch processing mode <|
|
||||
| batch_size<| Fixnum <| nil <| number of maximum items to be assigned at once<|
|
||||
| logger <| Logger <| nil <| logger instance for debug logs <|
|
||||
| Option ~| Type ~| Default~| Description ~|
|
||||
| -- ~| -- ~| -- ~| -- ~|
|
||||
| threads ~| Fixnum ~| 1 ~| number of threads in the thread pool ~|
|
||||
| queues ~| Fixnum ~| 1 ~| number of concurrent queues ~|
|
||||
| queue_size~| Fixnum ~| 1000 ~| size of each queue ~|
|
||||
| interval ~| Numeric~| 0 ~| dispatcher interval for batch processing ~|
|
||||
| batch ~| Boolean~| false ~| enables batch processing mode ~|
|
||||
| batch_size~| Fixnum ~| nil ~| number of maximum items to be assigned at once~|
|
||||
| logger ~| Logger ~| nil ~| logger instance for debug logs ~|
|
||||
|
||||
```c
|
||||
|
||||
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 |
|
||||
|
||||
|
||||
114
test/basic.md
114
test/basic.md
@@ -29,10 +29,10 @@ a = 1
|
||||
bbbb = 2
|
||||
ccccccc = 3
|
||||
ccccccccccccccc
|
||||
ddd = 4
|
||||
ddd = #
|
||||
eeee === eee = eee = eee=f
|
||||
fff = ggg += gg &&= gg
|
||||
g != hhhhhhhh == 888
|
||||
g != hhhhhhhh == # 8
|
||||
i := 5
|
||||
i %= 5
|
||||
i *= 5
|
||||
@@ -107,3 +107,113 @@ my_object.
|
||||
|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 +1 @@
|
||||
4Gvipjyvip
|
||||
4Gvipjyvip
|
||||
|
||||
@@ -16,6 +16,8 @@ function! GFM()
|
||||
\ lang, lang, lang)
|
||||
endfor
|
||||
let b:current_syntax='mkd'
|
||||
|
||||
syntax sync fromstart
|
||||
endfunction
|
||||
|
||||
silent! unlet g:easy_align_delimiters
|
||||
@@ -35,6 +37,7 @@ vnoremap <silent> <C-l> <nop>
|
||||
|
||||
set nolazyredraw
|
||||
set buftype=nofile
|
||||
set colorcolumn=
|
||||
|
||||
silent! ScrollPositionHide
|
||||
|
||||
|
||||
@@ -91,3 +91,6 @@ apricot = 'DAD' + 'F#AD'
|
||||
banana = 'Gros Michel' # comment 2
|
||||
```
|
||||
|
||||
a()p()p()l()e();():()b()a()n()a()n()a():():()c()a()k()e(
|
||||
d()a()t()a();();()e()x()c()h()a()n()g()e():();()f()o()r()m()a()t(
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
4Gvipjyvip:EasyAlign:
|
||||
4Gvipjyvip:EasyAlign:
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
e!
|
||||
execute 'source '. expand('%:p:h') . '/include.vim'
|
||||
|
||||
while line('.') < line('$')
|
||||
normal 30j
|
||||
redraw
|
||||
endwhile
|
||||
|
||||
normal gg
|
||||
let @b=system('cat '. expand('%:p:r') . '.script')
|
||||
let @a='@b:vert diffsplit ' . expand('%:p:r') . '.expected
|
||||
'
|
||||
" Syntax highlighting doesn't work
|
||||
'
|
||||
|
||||
Reference in New Issue
Block a user