Field index -> N-th parameter

This commit is contained in:
Junegunn Choi
2013-09-22 03:52:36 +09:00
parent 4cdc450126
commit 1d2c58c06a
5 changed files with 26 additions and 26 deletions

View File

@@ -70,8 +70,8 @@ mysql:
"user:pass":r00t:pa55
```
Using blockwise-visual mode or negative field index
---------------------------------------------------
Using blockwise-visual mode or negative N-th parameter
------------------------------------------------------
```ruby
options = { :caching => nil,

View File

@@ -166,8 +166,8 @@ my_object
```
Using blockwise-visual mode or negative field index
---------------------------------------------------
Using blockwise-visual mode or negative N-th parameter
------------------------------------------------------
You can try either:
- select text around `=>` in blockwise-visual mode (`CTRL-V`) and `<Enter>=`

View File

@@ -56,8 +56,8 @@ variant `:EasyAlign!`) for visual mode.
| Mode | Command |
| ------------------------- | ------------------------------------------------ |
| Interactive mode | `:EasyAlign[!] [OPTIONS]` |
| Using predefined rules | `:EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS]` |
| Using regular expressions | `:EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS]` |
| Using predefined rules | `:EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]` |
| Using regular expressions | `:EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]` |
### Concept of _alignment rule_
@@ -83,8 +83,8 @@ vnoremap <silent> <Enter> :EasyAlign<cr>
With the mapping, you can align selected lines of text with only a few keystrokes.
1. `<Enter>` key to start interactive EasyAlign command
1. Optional Enter keys to select alignment mode (left, right, or center)
1. Optional field index (default: 1)
1. Optional: Enter keys to select alignment mode (left, right, or center)
1. Optional: N-th delimiter (default: 1)
- `1` Around the 1st occurrences of delimiters
- `2` Around the 2nd occurrences of delimiters
- ...
@@ -176,10 +176,10 @@ Instead of going into the interactive mode, you can type in arguments to
```vim
" Using predefined alignment rules
:EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS]
:EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]
" Using arbitrary regular expressions
:EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS]
:EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]
```
For example, when aligning the following lines around colons and semi-colons,
@@ -247,7 +247,7 @@ my_hash = { :a => 1,
```
However, in this case, we don't really need blockwise visual mode
since the same can be easily done using the negative field index: `<Enter>-=`
since the same can be easily done using the negative N-th parameter: `<Enter>-=`
Alignment options
-----------------
@@ -508,7 +508,7 @@ let g:easy_align_bang_interactive_modes = ['c', 'r']
### Alignments over multiple occurrences of delimiters
As stated above, "field index" is used to target specific occurrences of
As stated above, "N-th" parameter is used to target specific occurrences of
the delimiter when it appears multiple times in each line.
To recap:

View File

@@ -364,12 +364,12 @@ function! s:do_align(modes, all_tokens, all_delims, fl, ll, fc, lc, pattern, nth
" Calculate the maximum number of tokens for a line within the range
call s:max(max, { 'tokens': len(tokens) })
if a:nth > 0 " Positive field number
if a:nth > 0 " Positive N-th
if len(tokens) < a:nth
continue
endif
let nth = a:nth - 1 " make it 0-based
else " -0 or Negative field number
else " -0 or Negative N-th
if a:nth == 0 && mode !=? 'l'
let nth = len(tokens) - 1
else
@@ -752,7 +752,7 @@ function! s:align(bang, first_line, last_line, expr)
elseif n == '-' | let nth = -1
elseif empty(n) | let nth = 1
elseif n == '0' || ( n != '-0' && n != string(str2nr(n)) )
call s:exit('Invalid field number: '. n)
call s:exit('Invalid N-th parameter: '. n)
else
let nth = n
endif

View File

@@ -16,11 +16,11 @@ EasyAlign *:EasyAlign* *:EasyAlign!*
vim-easy-align defines `:EasyAlign` command in the visual mode.
(:EasyAlign! is the right-align version.)
| Mode | Command |
| ------------------------- | ---------------------------------------------- |
| Interactive mode | :EasyAlign[!] [OPTIONS] |
| Using predefined rules | :EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS] |
| Using regular expressions | :EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS] |
| Mode | Command |
| ------------------------- | -------------------------------------------- |
| Interactive mode | :EasyAlign[!] [OPTIONS] |
| Using predefined rules | :EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS] |
| Using regular expressions | :EasyAlign[!] [N-th] /REGEXP/ [OPTIONS] |
Interactive mode
@@ -35,8 +35,8 @@ your `.vimrc`.
With this mapping, you can align selected lines of text with a few keystrokes.
1. <Enter> key to start interactive EasyAlign command
2. Optional Enter keys to select alignment mode (left, right, or center)
3. Optional field index (default: 1)
2. Optional: Enter keys to select alignment mode (left, right, or center)
3. Optional: N-th delimiter (default: 1)
1 Around the 1st occurrences of delimiters
2 Around the 2nd occurrences of delimiters
* Around all occurrences of delimiters
@@ -106,10 +106,10 @@ Instead of going into the interactive mode, you can type in arguments to
`:EasyAlign` command.
" Using predefined alignment rules
:EasyAlign[!] [FIELD#] DELIMITER_KEY [OPTIONS]
:EasyAlign[!] [N-th] DELIMITER_KEY [OPTIONS]
" Using arbitrary regular expressions
:EasyAlign[!] [FIELD#] /REGEXP/ [OPTIONS]
:EasyAlign[!] [N-th] /REGEXP/ [OPTIONS]
For example, when aligning the following lines around colons and semi-colons,
@@ -175,7 +175,7 @@ Available options are as follows.
| | | (right, left, center) |
| indentation | string | 'k' |
| | | (keep, shallow, deep, none) |
| mode_sequence | string | (Depends on field index and |
| mode_sequence | string | (Depends on N-th param and |
| | | selected alignment mode) |
There are 4 ways to set alignment options (from lowest precedence to highest):
@@ -407,7 +407,7 @@ settings as follows.
Alignments over multiple occurrences of delimiters
-------------------------------------------------------------------------
As stated above, "field index" is used to target specific occurrences of
As stated above, "N-th" parameter is used to target specific occurrences of
the delimiter when it appears multiple times in each line.
To recap: