diff --git a/README.md b/README.md
index b0c284b..47d9103 100644
--- a/README.md
+++ b/README.md
@@ -120,14 +120,34 @@ You can override these default rules or define your own rules with
#### Using regular expressions
Instead of finishing the command with a predefined delimiter key, you can type
-in a regular expression after `` key. For example, if you want to align
-text around all occurrences of numbers:
+in a regular expression after `` or `` key.
+For example, if you want to align text around all occurrences of numbers:
- ``
- `*`
-- ``
+- `` or ``
- `[0-9]\+`
+(`` key will not work in GVim, then you have to use `` instead)
+
+#### Alignment options in interactive mode
+
+While in interactive mode, you can switch some of the alignment options using
+special shortcut keys listed below. The meanings of the options will be
+described in the following sections.
+
+| Key | Option | Values |
+| -------- | ------------------ | -------------------------------------------------- |
+| `CTRL-I` | `indentation` | shallow, deep, none, keep |
+| `CTRL-L` | `left_margin` | Input number or string |
+| `CTRL-R` | `right_margin` | Input number or string |
+| `CTRL-D` | `delimiter_align` | left, center, right |
+| `CTRL-U` | `ignore_unmatched` | 0, 1 |
+| `CTRL-G` | `ignore_groups` | [], ['String'], ['Comment'], ['String', 'Comment'] |
+| `CTRL-O` | `mode_sequence` | Input string of `/[lrc]+\*{0,2}/` |
+| `` | `stick_to_left` | Set stick_to_left option |
+| `` | `stick_to_left` | Unset stick_to_left option |
+
---
### *Intermission*
@@ -246,19 +266,6 @@ Some of the options can be specified using corresponding global variables.
| `delimiter_align` | `g:easy_align_delimiter_align` |
| `indentation` | `g:easy_align_indentation` |
-In interactive mode, you can switch some of the alignment options using special
-keys listed below.
-
-| Key | Option | Values |
-| -------- | ------------------ | -------------------------------------------------- |
-| `CTRL-I` | `indentation` | shallow, deep, none, keep |
-| `CTRL-L` | `left_margin` | Input number or string |
-| `CTRL-R` | `right_margin` | Input number or string |
-| `CTRL-D` | `delimiter_align` | left, center, right |
-| `CTRL-U` | `ignore_unmatched` | 0, 1 |
-| `CTRL-G` | `ignore_groups` | [], ['String'], ['Comment'], ['String', 'Comment'] |
-| `CTRL-O` | `mode_sequence` | Input string of l, r, and c characters |
-
### Ignoring delimiters in comments or strings
EasyAlign can be configured to ignore delimiters in certain syntax highlight
diff --git a/autoload/easy_align.vim b/autoload/easy_align.vim
index 0b1fe3b..8eb1b97 100644
--- a/autoload/easy_align.vim
+++ b/autoload/easy_align.vim
@@ -480,8 +480,15 @@ function! s:do_align(modes, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth
endif
endfunction
-function! s:input(str, default)
- redraw
+function! s:input(str, default, sl)
+ if !a:sl
+ normal! gv
+ redraw
+ execute "normal! \"
+ else
+ " EasyAlign command can be called without visual selection
+ redraw
+ endif
call inputsave()
let got = input(a:str, a:default)
call inputrestore()
@@ -492,7 +499,7 @@ function! s:input(str, default)
endtry
endfunction
-function! s:interactive(modes)
+function! s:interactive(modes, sl)
let mode = s:shift(a:modes, 1)
let n = ''
let ch = ''
@@ -536,15 +543,19 @@ function! s:interactive(modes)
elseif ch == "\"
let opts['idt'] = s:shift(vals['indentation'], 1)
elseif ch == "\"
- let opts['lm'] = s:input("Left margin: ", get(opts, 'lm', ''))
+ let opts['lm'] = s:input("Left margin: ", get(opts, 'lm', ''), a:sl)
elseif ch == "\"
- let opts['rm'] = s:input("Right margin: ", get(opts, 'rm', ''))
+ let opts['rm'] = s:input("Right margin: ", get(opts, 'rm', ''), a:sl)
elseif ch == "\"
let opts['iu'] = s:shift(vals['ignore_unmatched'], 1)
elseif ch == "\"
let opts['ig'] = s:shift(vals['ignore_groups'], 1)
+ elseif c == "\"
+ let opts['stl'] = 1
+ elseif c == "\"
+ let opts['stl'] = 0
elseif ch == "\"
- let modes = tolower(s:input("Mode sequence: ", get(opts, 'm', mode)))
+ let modes = tolower(s:input("Mode sequence: ", get(opts, 'm', mode), a:sl))
if match(modes, '^[lrc]\+\*\{0,2}$') != -1
let opts['m'] = modes
let mode = modes[0]
@@ -553,8 +564,8 @@ function! s:interactive(modes)
else
silent! call remove(opts, 'm')
endif
- elseif ch == "\"
- let ch = s:input('Regular expression: ', '')
+ elseif ch == "\" || ch == "\"
+ let ch = s:input('Regular expression: ', '', a:sl)
if !empty(ch)
let regx = 1
break
@@ -634,14 +645,15 @@ function! easy_align#align(bang, expr) range
let ioptsr = {}
let iopts = {}
let regexp = 0
+ let sl = a:firstline == a:lastline " Possibley w/o selection
try
if empty(a:expr)
- let [mode, n, ch, ioptsr, iopts, regexp] = s:interactive(copy(modes))
+ let [mode, n, ch, ioptsr, iopts, regexp] = s:interactive(copy(modes), sl)
else
let [n, ch, opts, regexp] = s:parse_args(a:expr)
if empty(n) && empty(ch)
- let [mode, n, ch, ioptsr, iopts, regexp] = s:interactive(copy(modes))
+ let [mode, n, ch, ioptsr, iopts, regexp] = s:interactive(copy(modes), sl)
elseif empty(ch)
" Try swapping n and ch
let [n, ch] = ['', n]
diff --git a/doc/easy_align.txt b/doc/easy_align.txt
index 0486ddb..7d19c7a 100644
--- a/doc/easy_align.txt
+++ b/doc/easy_align.txt
@@ -72,12 +72,38 @@ Examples:
**= Right-left alternating alignment around all equals signs
+Instead of finishing the command with a predefined delimiter key, you can type
+in a regular expression after `` or `` key.
+For example, if you want to align text around all occurrences of numbers:
+
+-
+- *
+- or
+ - [0-9]\+
+
+
+While in interactive mode, you can adjust some of the alignment options using
+special shortcut keys listed below. The meanings of the options will be
+described in the following sections.
+
+| Key | Option | Values |
+| ------- | ---------------- | ------------------------------------------ |
+| CTRL-I | indentation | shallow, deep, none, keep |
+| CTRL-L | left_margin | Input number or string |
+| CTRL-R | right_margin | Input number or string |
+| CTRL-D | delimiter_align | left, center, right |
+| CTRL-U | ignore_unmatched | 0, 1 |
+| CTRL-G | ignore_groups | [], [String], [Comment], [String, Comment] |
+| CTRL-O | mode_sequence | Input string of /[lrc]+\*{0,2}/ |
+| | stick_to_left | Set stick_to_left option |
+| | stick_to_left | Unset stick_to_left option |
+
+
Non-interactive mode
-------------------------------------------------------------------------
Instead of going into the interactive mode, you can type in arguments to
-`:EasyAlign` command. In non-interactive mode, you can even use arbitrary
-regular expressions.
+`:EasyAlign` command.
" Using predefined alignment rules
:EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS]
@@ -424,6 +450,14 @@ in interactive mode with the special key CTRL-O)
" Right, left, center, right, left, center, ...
:EasyAlign **={ 'm': 'rlc' }
+ " Right, left, center, center, center, ... repeating alignment
+ " over the 3rd to the last occurrences of delimiters
+ :EasyAlign 3={ 'm': 'rlc*' }
+
+ " Right, left, center, right, left, center, ... alternating alignment
+ " over the 3rd to the last occurrences of delimiters
+ :EasyAlign 3={ 'm': 'rlc**' }
+
Extending alignment rules *g:easy_align_delimiters*
-------------------------------------------------------------------------