1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 02:00:05 +08:00

Add: add two new key bindings: align at [SPC] and operators. (#2571)

* Add: add a new key binding: align at [SPC].

* Add: add a new key binding: align at operators.
This commit is contained in:
Lin Kun 2019-02-11 09:35:41 +08:00 committed by Wang Shidong
parent 972fb6d04d
commit 0c8be4f18e
5 changed files with 130 additions and 118 deletions

View File

@ -81,8 +81,10 @@ function! SpaceVim#layers#edit#config() abort
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ':'], 'Tabularize /:', 'align region at :', 1) call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ':'], 'Tabularize /:', 'align region at :', 1)
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ';'], 'Tabularize /;', 'align region at ;', 1) call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', ';'], 'Tabularize /;', 'align region at ;', 1)
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '='], 'Tabularize /===\|<=>\|\(&&\|||\|<<\|>>\|\/\/\)=\|=\~[#?]\?\|=>\|[:+/*!%^=><&|.?-]\?=[#?]\?/l1r1', 'align region at =', 1) call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '='], 'Tabularize /===\|<=>\|\(&&\|||\|<<\|>>\|\/\/\)=\|=\~[#?]\?\|=>\|[:+/*!%^=><&|.?-]\?=[#?]\?/l1r1', 'align region at =', 1)
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', 'o'], 'Tabularize /&&\|||\|\.\.\|\*\*\|<<\|>>\|\/\/\|[-+*/.%^><&|?]/l1r1', 'align region at operator, such as +,-,*,/,%,^,etc', 1)
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '¦'], 'Tabularize /¦', 'align region at ¦', 1) call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '¦'], 'Tabularize /¦', 'align region at ¦', 1)
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '<Bar>'], 'Tabularize /|', 'align region at |', 1) call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '<Bar>'], 'Tabularize /|', 'align region at |', 1)
call SpaceVim#mapping#space#def('nnoremap', ['x', 'a', '[SPC]'], 'Tabularize /\s\+', 'align region at [SPC]', 1)
call SpaceVim#mapping#space#def('nnoremap', ['x', 'd', 'w'], 'StripWhitespace', 'delete trailing whitespaces', 1) call SpaceVim#mapping#space#def('nnoremap', ['x', 'd', 'w'], 'StripWhitespace', 'delete trailing whitespaces', 1)
call SpaceVim#mapping#space#def('nnoremap', ['x', 'd', '[SPC]'], 'silent call call(' call SpaceVim#mapping#space#def('nnoremap', ['x', 'd', '[SPC]'], 'silent call call('
\ . string(s:_function('s:delete_extra_space')) . ', [])', \ . string(s:_function('s:delete_extra_space')) . ', [])',

View File

@ -1519,62 +1519,63 @@ In highlight symbol transient state:
文本相关的命令 (以 `x` 开头) 文本相关的命令 (以 `x` 开头)
| 快捷键 | 描述 | | 快捷键 | 描述 |
| ------------- | -------------------------------------------------------------------- | | --------------- | -------------------------------------------------------------------- |
| `SPC x a &` | align region at & | | `SPC x a &` | align region at & |
| `SPC x a (` | align region at ( | | `SPC x a (` | align region at ( |
| `SPC x a )` | align region at ) | | `SPC x a )` | align region at ) |
| `SPC x a [` | align region at [ | | `SPC x a [` | align region at [ |
| `SPC x a ]` | align region at ] | | `SPC x a ]` | align region at ] |
| `SPC x a {` | align region at { | | `SPC x a {` | align region at { |
| `SPC x a }` | align region at } | | `SPC x a }` | align region at } |
| `SPC x a ,` | align region at , | | `SPC x a ,` | align region at , |
| `SPC x a .` | align region at . (for numeric tables) | | `SPC x a .` | align region at . (for numeric tables) |
| `SPC x a :` | align region at : | | `SPC x a :` | align region at : |
| `SPC x a ;` | align region at ; | | `SPC x a ;` | align region at ; |
| `SPC x a =` | align region at = | | `SPC x a =` | align region at = |
| `SPC x a ¦` | align region at ¦ | | `SPC x a ¦` | align region at ¦ |
| `SPC x a |` | align region at | | | `SPC x a |` | align region at | |
| `SPC x a a` | align region (or guessed section) using default rules (TODO) | | `SPC x a [SPC]` | align region at [SPC] |
| `SPC x a c` | align current indentation region using default rules (TODO) | | `SPC x a a` | align region (or guessed section) using default rules (TODO) |
| `SPC x a l` | left-align with evil-lion (TODO) | | `SPC x a c` | align current indentation region using default rules (TODO) |
| `SPC x a L` | right-align with evil-lion (TODO) | | `SPC x a l` | left-align with evil-lion (TODO) |
| `SPC x a r` | align region using user-specified regexp (TODO) | | `SPC x a L` | right-align with evil-lion (TODO) |
| `SPC x a m` | align region at arithmetic operators `(+-*/)` (TODO) | | `SPC x a r` | align region using user-specified regexp (TODO) |
| `SPC x c` | count the number of chars/words/lines in the selection region | | `SPC x a o` | align region at arithmetic operators `+-*/` |
| `SPC x d w` | delete trailing whitespaces | | `SPC x c` | count the number of chars/words/lines in the selection region |
| `SPC x d SPC` | Delete all spaces and tabs around point, leaving one space | | `SPC x d w` | delete trailing whitespaces |
| `SPC x g l` | set lanuages used by translate commands (TODO) | | `SPC x d SPC` | Delete all spaces and tabs around point, leaving one space |
| `SPC x g t` | translate current word using Google Translate | | `SPC x g l` | set lanuages used by translate commands (TODO) |
| `SPC x g T` | reverse source and target languages (TODO) | | `SPC x g t` | translate current word using Google Translate |
| `SPC x i c` | change symbol style to `lowerCamelCase` | | `SPC x g T` | reverse source and target languages (TODO) |
| `SPC x i C` | change symbol style to `UpperCamelCase` | | `SPC x i c` | change symbol style to `lowerCamelCase` |
| `SPC x i i` | cycle symbol naming styles (i to keep cycling) | | `SPC x i C` | change symbol style to `UpperCamelCase` |
| `SPC x i -` | change symbol style to `kebab-case` | | `SPC x i i` | cycle symbol naming styles (i to keep cycling) |
| `SPC x i k` | change symbol style to `kebab-case` | | `SPC x i -` | change symbol style to `kebab-case` |
| `SPC x i _` | change symbol style to `under_score` | | `SPC x i k` | change symbol style to `kebab-case` |
| `SPC x i u` | change symbol style to `under_score` | | `SPC x i _` | change symbol style to `under_score` |
| `SPC x i U` | change symbol style to `UP_CASE` | | `SPC x i u` | change symbol style to `under_score` |
| `SPC x j c` | 居中对齐当前段落 | | `SPC x i U` | change symbol style to `UP_CASE` |
| `SPC x j f` | set the justification to full (TODO) | | `SPC x j c` | 居中对齐当前段落 |
| `SPC x j l` | 左对齐当前段落 | | `SPC x j f` | set the justification to full (TODO) |
| `SPC x j n` | set the justification to none (TODO) | | `SPC x j l` | 左对齐当前段落 |
| `SPC x j r` | 右对齐当前段落 | | `SPC x j n` | set the justification to none (TODO) |
| `SPC x J` | move down a line of text (enter transient state) | | `SPC x j r` | 右对齐当前段落 |
| `SPC x K` | move up a line of text (enter transient state) | | `SPC x J` | move down a line of text (enter transient state) |
| `SPC x l d` | duplicate line or region (TODO) | | `SPC x K` | move up a line of text (enter transient state) |
| `SPC x l s` | sort lines (TODO) | | `SPC x l d` | duplicate line or region (TODO) |
| `SPC x l u` | uniquify lines (TODO) | | `SPC x l s` | sort lines (TODO) |
| `SPC x o` | use avy to select a link in the frame and open it (TODO) | | `SPC x l u` | uniquify lines (TODO) |
| `SPC x O` | use avy to select multiple links in the frame and open them (TODO) | | `SPC x o` | use avy to select a link in the frame and open it (TODO) |
| `SPC x t c` | swap (transpose) the current character with the previous one | | `SPC x O` | use avy to select multiple links in the frame and open them (TODO) |
| `SPC x t w` | swap (transpose) the current word with the previous one | | `SPC x t c` | swap (transpose) the current character with the previous one |
| `SPC x t l` | swap (transpose) the current line with the previous one | | `SPC x t w` | swap (transpose) the current word with the previous one |
| `SPC x u` | set the selected text to lower case (TODO) | | `SPC x t l` | swap (transpose) the current line with the previous one |
| `SPC x U` | set the selected text to upper case (TODO) | | `SPC x u` | set the selected text to lower case (TODO) |
| `SPC x w c` | count the number of occurrences per word in the select region (TODO) | | `SPC x U` | set the selected text to upper case (TODO) |
| `SPC x w d` | show dictionary entry of word from wordnik.com (TODO) | | `SPC x w c` | count the number of occurrences per word in the select region (TODO) |
| `SPC x TAB` | indent or dedent a region rigidly (TODO) | | `SPC x w d` | show dictionary entry of word from wordnik.com (TODO) |
| `SPC x TAB` | indent or dedent a region rigidly (TODO) |
#### 文本插入命令 #### 文本插入命令

View File

@ -45,6 +45,7 @@ lang: cn
- `=`: 对齐 `===`, `==`, `!=`, `>=` - `=`: 对齐 `===`, `==`, `!=`, `>=`
- `&`: 对齐 `&` - `&`: 对齐 `&`
- `¦`: 对齐 `¦` - `¦`: 对齐 `¦`
- `|`: 对齐 `|`
- `;`: 对齐 `;` - `;`: 对齐 `;`
- `:`: 对齐 `:` - `:`: 对齐 `:`
- `,`: 对齐 `,` - `,`: 对齐 `,`
@ -55,6 +56,8 @@ lang: cn
- `]`: 对齐 `]` - `]`: 对齐 `]`
- `}`: 对齐 `}` - `}`: 对齐 `}`
- `)`: 对齐 `)` - `)`: 对齐 `)`
- `[SPC]`: 对齐 `[SPC]`
- `o`: 对齐 `+ - * / % ^`
| 快捷键 | 功能描述 | | 快捷键 | 功能描述 |
| ------------ | ------------------------------------ | | ------------ | ------------------------------------ |

View File

@ -1553,62 +1553,63 @@ In highlight symbol transient state:
Text related commands (start with `x`): Text related commands (start with `x`):
| Key Bindings | Descriptions | | Key Bindings | Descriptions |
| ------------- | -------------------------------------------------------------------- | | --------------- | -------------------------------------------------------------------- |
| `SPC x a &` | align region at & | | `SPC x a &` | align region at & |
| `SPC x a (` | align region at ( | | `SPC x a (` | align region at ( |
| `SPC x a )` | align region at ) | | `SPC x a )` | align region at ) |
| `SPC x a [` | align region at \[ | | `SPC x a [` | align region at \[ |
| `SPC x a ]` | align region at ] | | `SPC x a ]` | align region at ] |
| `SPC x a {` | align region at { | | `SPC x a {` | align region at { |
| `SPC x a }` | align region at } | | `SPC x a }` | align region at } |
| `SPC x a ,` | align region at , | | `SPC x a ,` | align region at , |
| `SPC x a .` | align region at . (for numeric tables) | | `SPC x a .` | align region at . (for numeric tables) |
| `SPC x a :` | align region at : | | `SPC x a :` | align region at : |
| `SPC x a ;` | align region at ; | | `SPC x a ;` | align region at ; |
| `SPC x a =` | align region at = | | `SPC x a =` | align region at = |
| `SPC x a ¦` | align region at ¦ | | `SPC x a ¦` | align region at ¦ |
| `SPC x a |` | align region at | | | `SPC x a |` | align region at | |
| `SPC x a a` | align region (or guessed section) using default rules (TODO) | | `SPC x a [SPC]` | align region at [SPC] |
| `SPC x a c` | align current indentation region using default rules (TODO) | | `SPC x a a` | align region (or guessed section) using default rules (TODO) |
| `SPC x a l` | left-align with evil-lion (TODO) | | `SPC x a c` | align current indentation region using default rules (TODO) |
| `SPC x a L` | right-align with evil-lion (TODO) | | `SPC x a l` | left-align with evil-lion (TODO) |
| `SPC x a r` | align region using user-specified regexp (TODO) | | `SPC x a L` | right-align with evil-lion (TODO) |
| `SPC x a m` | align region at arithmetic operators `(+-*/)` (TODO) | | `SPC x a r` | align region using user-specified regexp (TODO) |
| `SPC x c` | count the number of chars/words/lines in the selection region | | `SPC x a o` | align region at operators `+-*/` |
| `SPC x d w` | delete trailing whitespaces | | `SPC x c` | count the number of chars/words/lines in the selection region |
| `SPC x d SPC` | Delete all spaces and tabs around point, leaving one space | | `SPC x d w` | delete trailing whitespaces |
| `SPC x g l` | set lanuages used by translate commands (TODO) | | `SPC x d SPC` | Delete all spaces and tabs around point, leaving one space |
| `SPC x g t` | translate current word using Google Translate | | `SPC x g l` | set lanuages used by translate commands (TODO) |
| `SPC x g T` | reverse source and target languages (TODO) | | `SPC x g t` | translate current word using Google Translate |
| `SPC x i c` | change symbol style to `lowerCamelCase` | | `SPC x g T` | reverse source and target languages (TODO) |
| `SPC x i C` | change symbol style to `UpperCamelCase` | | `SPC x i c` | change symbol style to `lowerCamelCase` |
| `SPC x i i` | cycle symbol naming styles (i to keep cycling) | | `SPC x i C` | change symbol style to `UpperCamelCase` |
| `SPC x i -` | change symbol style to `kebab-case` | | `SPC x i i` | cycle symbol naming styles (i to keep cycling) |
| `SPC x i k` | change symbol style to `kebab-case` | | `SPC x i -` | change symbol style to `kebab-case` |
| `SPC x i _` | change symbol style to `under_score` | | `SPC x i k` | change symbol style to `kebab-case` |
| `SPC x i u` | change symbol style to `under_score` | | `SPC x i _` | change symbol style to `under_score` |
| `SPC x i U` | change symbol style to `UP_CASE` | | `SPC x i u` | change symbol style to `under_score` |
| `SPC x j c` | set the justification to center | | `SPC x i U` | change symbol style to `UP_CASE` |
| `SPC x j f` | set the justification to full (TODO) | | `SPC x j c` | set the justification to center |
| `SPC x j l` | set the justification to left | | `SPC x j f` | set the justification to full (TODO) |
| `SPC x j n` | set the justification to none (TODO) | | `SPC x j l` | set the justification to left |
| `SPC x j r` | set the justification to right | | `SPC x j n` | set the justification to none (TODO) |
| `SPC x J` | move down a line of text (enter transient state) | | `SPC x j r` | set the justification to right |
| `SPC x K` | move up a line of text (enter transient state) | | `SPC x J` | move down a line of text (enter transient state) |
| `SPC x l d` | duplicate line or region (TODO) | | `SPC x K` | move up a line of text (enter transient state) |
| `SPC x l s` | sort lines (TODO) | | `SPC x l d` | duplicate line or region (TODO) |
| `SPC x l u` | uniquify lines (TODO) | | `SPC x l s` | sort lines (TODO) |
| `SPC x o` | use avy to select a link in the frame and open it (TODO) | | `SPC x l u` | uniquify lines (TODO) |
| `SPC x O` | use avy to select multiple links in the frame and open them (TODO) | | `SPC x o` | use avy to select a link in the frame and open it (TODO) |
| `SPC x t c` | swap (transpose) the current character with the previous one | | `SPC x O` | use avy to select multiple links in the frame and open them (TODO) |
| `SPC x t w` | swap (transpose) the current word with the previous one | | `SPC x t c` | swap (transpose) the current character with the previous one |
| `SPC x t l` | swap (transpose) the current line with the previous one | | `SPC x t w` | swap (transpose) the current word with the previous one |
| `SPC x u` | set the selected text to lower case (TODO) | | `SPC x t l` | swap (transpose) the current line with the previous one |
| `SPC x U` | set the selected text to upper case (TODO) | | `SPC x u` | set the selected text to lower case (TODO) |
| `SPC x w c` | count the number of occurrences per word in the select region (TODO) | | `SPC x U` | set the selected text to upper case (TODO) |
| `SPC x w d` | show dictionary entry of word from wordnik.com (TODO) | | `SPC x w c` | count the number of occurrences per word in the select region (TODO) |
| `SPC x TAB` | indent or dedent a region rigidly (TODO) | | `SPC x w d` | show dictionary entry of word from wordnik.com (TODO) |
| `SPC x TAB` | indent or dedent a region rigidly (TODO) |
#### Text insertion commands #### Text insertion commands

View File

@ -35,7 +35,7 @@ This layer provides many edit key bindings for SpaceVim, and also provides more
## Key bindings ## Key bindings
| Key bindings | Descraptions | | Key bindings | Descraptions |
| -------------------- | ------------------------------- | | -------------------- | -------------------------------- |
| `SPC x a {delimiter}` | align content based on delimiter | | `SPC x a {delimiter}` | align content based on delimiter |
**default delimiters** **default delimiters**
@ -43,6 +43,7 @@ This layer provides many edit key bindings for SpaceVim, and also provides more
- `=`: align `===`, `==`, `!=`, `>=` etc. - `=`: align `===`, `==`, `!=`, `>=` etc.
- `&`: align `&` - `&`: align `&`
- `¦`: align `¦` - `¦`: align `¦`
- `|`: align `|`
- `;`: align `;` - `;`: align `;`
- `:`: align `:` - `:`: align `:`
- `,`: align `,` - `,`: align `,`
@ -53,9 +54,13 @@ This layer provides many edit key bindings for SpaceVim, and also provides more
- `]`: align `]` - `]`: align `]`
- `}`: align `}` - `}`: align `}`
- `)`: align `)` - `)`: align `)`
- `[SPC]`: align `[SPC]`
- `o`: align `+ - * / % ^` etc.
| Key bindings | Descraptions | | Key bindings | Descraptions |
| ------------ | ------------------------------- | | ------------ | ------------------------------------ |
| `SPC x j c` | set the justification to center | | `SPC x j c` | set the justification to center |
| `SPC x j l` | set the justification to left | | `SPC x j f` | set the justification to full (TODO) |
| `SPC x j r` | set the justification to right | | `SPC x j l` | set the justification to left |
| `SPC x j n` | set the justification to none (TODO) |
| `SPC x j r` | set the justification to right |