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 /===\|<=>\|\(&&\|||\|<<\|>>\|\/\/\)=\|=\~[#?]\?\|=>\|[:+/*!%^=><&|.?-]\?=[#?]\?/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', '<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', '[SPC]'], 'silent call call('
\ . string(s:_function('s:delete_extra_space')) . ', [])',

View File

@ -1520,7 +1520,7 @@ In highlight symbol transient state:
文本相关的命令 (以 `x` 开头)
| 快捷键 | 描述 |
| ------------- | -------------------------------------------------------------------- |
| --------------- | -------------------------------------------------------------------- |
| `SPC x a &` | align region at & |
| `SPC x a (` | align region at ( |
| `SPC x a )` | align region at ) |
@ -1535,12 +1535,13 @@ In highlight symbol transient state:
| `SPC x a =` | align region at = |
| `SPC x a ¦` | align region at ¦ |
| `SPC x a |` | align region at | |
| `SPC x a [SPC]` | align region at [SPC] |
| `SPC x a a` | align region (or guessed section) using default rules (TODO) |
| `SPC x a c` | align current indentation region using default rules (TODO) |
| `SPC x a l` | left-align with evil-lion (TODO) |
| `SPC x a L` | right-align with evil-lion (TODO) |
| `SPC x a r` | align region using user-specified regexp (TODO) |
| `SPC x a m` | align region at arithmetic operators `(+-*/)` (TODO) |
| `SPC x a o` | align region at arithmetic operators `+-*/` |
| `SPC x c` | count the number of chars/words/lines in the selection region |
| `SPC x d w` | delete trailing whitespaces |
| `SPC x d SPC` | Delete all spaces and tabs around point, leaving one space |

View File

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

View File

@ -1554,7 +1554,7 @@ In highlight symbol transient state:
Text related commands (start with `x`):
| Key Bindings | Descriptions |
| ------------- | -------------------------------------------------------------------- |
| --------------- | -------------------------------------------------------------------- |
| `SPC x a &` | align region at & |
| `SPC x a (` | align region at ( |
| `SPC x a )` | align region at ) |
@ -1569,12 +1569,13 @@ Text related commands (start with `x`):
| `SPC x a =` | align region at = |
| `SPC x a ¦` | align region at ¦ |
| `SPC x a |` | align region at | |
| `SPC x a [SPC]` | align region at [SPC] |
| `SPC x a a` | align region (or guessed section) using default rules (TODO) |
| `SPC x a c` | align current indentation region using default rules (TODO) |
| `SPC x a l` | left-align with evil-lion (TODO) |
| `SPC x a L` | right-align with evil-lion (TODO) |
| `SPC x a r` | align region using user-specified regexp (TODO) |
| `SPC x a m` | align region at arithmetic operators `(+-*/)` (TODO) |
| `SPC x a o` | align region at operators `+-*/` |
| `SPC x c` | count the number of chars/words/lines in the selection region |
| `SPC x d w` | delete trailing whitespaces |
| `SPC x d SPC` | Delete all spaces and tabs around point, leaving one space |

View File

@ -35,7 +35,7 @@ This layer provides many edit key bindings for SpaceVim, and also provides more
## Key bindings
| Key bindings | Descraptions |
| -------------------- | ------------------------------- |
| -------------------- | -------------------------------- |
| `SPC x a {delimiter}` | align content based on delimiter |
**default delimiters**
@ -43,6 +43,7 @@ This layer provides many edit key bindings for SpaceVim, and also provides more
- `=`: align `===`, `==`, `!=`, `>=` etc.
- `&`: 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 `)`
- `[SPC]`: align `[SPC]`
- `o`: align `+ - * / % ^` etc.
| Key bindings | Descraptions |
| ------------ | ------------------------------- |
| ------------ | ------------------------------------ |
| `SPC x j c` | set the justification to center |
| `SPC x j f` | set the justification to full (TODO) |
| `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 |