From a98c1ccc99022caaf9f04018b605479c4ee833c9 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 20 Jun 2014 10:34:00 +0900 Subject: [PATCH] Add '#'-rule (#30) For Ruby/Python comments. This new '#' rule will only match '#' characters that are highlighted as comments. --- EXAMPLES.md | 3 +++ README.md | 11 +++++++---- autoload/easy_align.vim | 2 ++ test/interactive.vader | 4 ---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index d7dd685..d4c6dda 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -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 diff --git a/README.md b/README.md index 0893fe7..fc90674 100644 --- a/README.md +++ b/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 | | `` | 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 \ } \ } diff --git a/autoload/easy_align.vim b/autoload/easy_align.vim index 0cc3147..c5a061f 100644 --- a/autoload/easy_align.vim +++ b/autoload/easy_align.vim @@ -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': '\\\@\#