mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-12 03:43:48 -05:00
Add '#'-rule (#30)
For Ruby/Python comments. This new '#' rule will only match '#' characters that are highlighted as comments.
This commit is contained in:
@@ -218,6 +218,9 @@ This only works when syntax highlighting is enabled.
|
|||||||
Aligning in-line comments
|
Aligning in-line comments
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
|
*Note: Since the current version provides '#'-rule as one of the default rules,
|
||||||
|
you can ignore this section*
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
apple = 1 # comment not aligned
|
apple = 1 # comment not aligned
|
||||||
banana = 'Gros Michel' # comment 2
|
banana = 'Gros Michel' # comment 2
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ With these mappings, you can align text with only a few keystrokes.
|
|||||||
| `.` | Multi-line method chaining |
|
| `.` | Multi-line method chaining |
|
||||||
| `,` | Multi-line method arguments |
|
| `,` | Multi-line method arguments |
|
||||||
| `&` | LaTeX tables (matches `&` and `\\`) |
|
| `&` | LaTeX tables (matches `&` and `\\`) |
|
||||||
|
| `#` | Ruby/Python comments |
|
||||||
| `<Bar>` | Table markdown |
|
| `<Bar>` | Table markdown |
|
||||||
|
|
||||||
You can override these default rules or define your own rules with
|
You can override these default rules or define your own rules with
|
||||||
@@ -670,8 +671,10 @@ You may refer to the definitions of the default alignment rules
|
|||||||
```vim
|
```vim
|
||||||
let g:easy_align_delimiters = {
|
let g:easy_align_delimiters = {
|
||||||
\ '>': { 'pattern': '>>\|=>\|>' },
|
\ '>': { 'pattern': '>>\|=>\|>' },
|
||||||
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignore_groups': ['String'] },
|
\ '/': {
|
||||||
\ '#': { 'pattern': '#\+', 'ignore_groups': ['String'], 'delimiter_align': 'l' },
|
\ 'pattern': '//\+\|/\*\|\*/',
|
||||||
|
\ 'delimiter_align': 'l',
|
||||||
|
\ 'ignore_groups': ['^\(.\(Comment\)\@!\)*$'] },
|
||||||
\ ']': {
|
\ ']': {
|
||||||
\ 'pattern': '[[\]]',
|
\ 'pattern': '[[\]]',
|
||||||
\ 'left_margin': 0,
|
\ 'left_margin': 0,
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ let s:easy_align_delimiters_default = {
|
|||||||
\ ',': { 'pattern': ',', 'left_margin': 0, 'right_margin': 1, 'stick_to_left': 1 },
|
\ ',': { 'pattern': ',', 'left_margin': 0, 'right_margin': 1, 'stick_to_left': 1 },
|
||||||
\ '|': { 'pattern': '|', 'left_margin': 1, 'right_margin': 1, 'stick_to_left': 0 },
|
\ '|': { 'pattern': '|', 'left_margin': 1, 'right_margin': 1, 'stick_to_left': 0 },
|
||||||
\ '.': { 'pattern': '\.', 'left_margin': 0, 'right_margin': 0, 'stick_to_left': 0 },
|
\ '.': { 'pattern': '\.', 'left_margin': 0, 'right_margin': 0, 'stick_to_left': 0 },
|
||||||
|
\ '#': { 'pattern': '#\+',
|
||||||
|
\ 'delimiter_align': 'l', 'ignore_groups': ['^\(.\(Comment\)\@!\)*$'] },
|
||||||
\ '&': { 'pattern': '\\\@<!&\|\\\\',
|
\ '&': { 'pattern': '\\\@<!&\|\\\\',
|
||||||
\ 'left_margin': 1, 'right_margin': 1, 'stick_to_left': 0 },
|
\ 'left_margin': 1, 'right_margin': 1, 'stick_to_left': 0 },
|
||||||
\ '{': { 'pattern': '(\@<!{',
|
\ '{': { 'pattern': '(\@<!{',
|
||||||
|
|||||||
@@ -893,10 +893,6 @@ Expect ruby:
|
|||||||
apricot = 'DAD' + 'F#AD'
|
apricot = 'DAD' + 'F#AD'
|
||||||
banana = 'Gros Michel' ## comment 2
|
banana = 'Gros Michel' ## comment 2
|
||||||
|
|
||||||
Execute (define # rule):
|
|
||||||
let g:easy_align_delimiters =
|
|
||||||
\ { '#': { 'pattern': '#\+', 'ignores': ['String'], 'delimiter_align': 'l' } }
|
|
||||||
|
|
||||||
Do (using # rule):
|
Do (using # rule):
|
||||||
vip\<Enter>\<C-U>#
|
vip\<Enter>\<C-U>#
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user