Add '#'-rule (#30)

For Ruby/Python comments. This new '#' rule will only match
'#' characters that are highlighted as comments.
This commit is contained in:
Junegunn Choi
2014-06-20 10:34:00 +09:00
parent 0aa6289d8c
commit a98c1ccc99
4 changed files with 12 additions and 8 deletions

View File

@@ -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

View File

@@ -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
\ }
\ }

View File

@@ -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': '(\@<!{',

View File

@@ -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>#