mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-11 19:33:50 -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
|
||||
-------------------------
|
||||
|
||||
*Note: Since the current version provides '#'-rule as one of the default rules,
|
||||
you can ignore this section*
|
||||
|
||||
```ruby
|
||||
apple = 1 # comment not aligned
|
||||
banana = 'Gros Michel' # comment 2
|
||||
|
||||
11
README.md
11
README.md
@@ -161,6 +161,7 @@ With these mappings, you can align text with only a few keystrokes.
|
||||
| `.` | Multi-line method chaining |
|
||||
| `,` | Multi-line method arguments |
|
||||
| `&` | LaTeX tables (matches `&` and `\\`) |
|
||||
| `#` | Ruby/Python comments |
|
||||
| `<Bar>` | Table markdown |
|
||||
|
||||
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
|
||||
let g:easy_align_delimiters = {
|
||||
\ '>': { 'pattern': '>>\|=>\|>' },
|
||||
\ '/': { 'pattern': '//\+\|/\*\|\*/', 'ignore_groups': ['String'] },
|
||||
\ '#': { 'pattern': '#\+', 'ignore_groups': ['String'], 'delimiter_align': 'l' },
|
||||
\ '/': {
|
||||
\ 'pattern': '//\+\|/\*\|\*/',
|
||||
\ 'delimiter_align': 'l',
|
||||
\ 'ignore_groups': ['^\(.\(Comment\)\@!\)*$'] },
|
||||
\ ']': {
|
||||
\ 'pattern': '[[\]]',
|
||||
\ 'left_margin': 0,
|
||||
@@ -685,8 +688,8 @@ let g:easy_align_delimiters = {
|
||||
\ 'stick_to_left': 0
|
||||
\ },
|
||||
\ 'd': {
|
||||
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
|
||||
\ 'left_margin': 0,
|
||||
\ 'pattern': ' \(\S\+\s*[;=]\)\@=',
|
||||
\ 'left_margin': 0,
|
||||
\ 'right_margin': 0
|
||||
\ }
|
||||
\ }
|
||||
|
||||
@@ -37,6 +37,8 @@ let s:easy_align_delimiters_default = {
|
||||
\ ',': { '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': 0, 'right_margin': 0, 'stick_to_left': 0 },
|
||||
\ '#': { 'pattern': '#\+',
|
||||
\ 'delimiter_align': 'l', 'ignore_groups': ['^\(.\(Comment\)\@!\)*$'] },
|
||||
\ '&': { 'pattern': '\\\@<!&\|\\\\',
|
||||
\ 'left_margin': 1, 'right_margin': 1, 'stick_to_left': 0 },
|
||||
\ '{': { 'pattern': '(\@<!{',
|
||||
|
||||
@@ -893,10 +893,6 @@ Expect ruby:
|
||||
apricot = 'DAD' + 'F#AD'
|
||||
banana = 'Gros Michel' ## comment 2
|
||||
|
||||
Execute (define # rule):
|
||||
let g:easy_align_delimiters =
|
||||
\ { '#': { 'pattern': '#\+', 'ignores': ['String'], 'delimiter_align': 'l' } }
|
||||
|
||||
Do (using # rule):
|
||||
vip\<Enter>\<C-U>#
|
||||
|
||||
|
||||
Reference in New Issue
Block a user