1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 13:30:05 +08:00

Improve align feature (#2213)

This commit is contained in:
Wang Shidong 2018-12-20 23:19:44 +08:00 committed by GitHub
parent c92ed6a45d
commit 61476ef530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 165 additions and 117 deletions

View File

@ -28,7 +28,7 @@ function! SpaceVim#layers#edit#plugins() abort
\ ['haya14busa/vim-easyoperator-line'],
\ ['editorconfig/editorconfig-vim', { 'merged' : 0, 'if' : has('python') || has('python3')}],
\ ['osyo-manga/vim-jplus', { 'on_map' : '<Plug>(jplus' }],
\ ['godlygeek/tabular', { 'on_cmd' : 'Tabularize'}],
\ ['godlygeek/tabular', { 'merged' : 0}],
\ ['ntpeters/vim-better-whitespace', { 'on_cmd' : ['StripWhitespace', 'ToggleWhitespace', 'DisableWhitespace', 'EnableWhitespace']}],
\ ]
if executable('fcitx')
@ -80,7 +80,7 @@ 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 /===\|<=>\|\(&&\|||\|<<\|>>\)=\|=\~[#?]\?\|=>\|[:+/*!%^=><&|.?-]\?=[#?]\?', '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', 'd', 'w'], 'StripWhitespace', 'delete trailing whitespaces', 1)
@ -506,7 +506,7 @@ endif
augroup spacevim_layer_edit
au!
autocmd BufNewFile *.py call <SID>add_buffer_head()
autocmd BufNewFile * call <SID>add_buffer_head()
augroup END
let s:ft_head_tp = {}
function! s:add_buffer_head() abort

View File

@ -1514,62 +1514,62 @@ In highlight symbol transient state:
文本相关的命令 (以 `x` 开头):
| Key Binding | Description | |
| ------------- | -------------------------------------------------------------------- | --- |
| `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 : | |
| `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 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 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 | |
| `SPC x g l` | set lanuages used by translate commands (TODO) | |
| `SPC x g t` | translate current word using Google Translate | |
| `SPC x g T` | reverse source and target languages (TODO) | |
| `SPC x i c` | change symbol style to `lowerCamelCase` | |
| `SPC x i C` | change symbol style to `UpperCamelCase` | |
| `SPC x i i` | cycle symbol naming styles (i to keep cycling) | |
| `SPC x i -` | change symbol style to `kebab-case` | |
| `SPC x i k` | change symbol style to `kebab-case` | |
| `SPC x i _` | change symbol style to `under_score` | |
| `SPC x i u` | change symbol style to `under_score` | |
| `SPC x i U` | change symbol style to `UP_CASE` | |
| `SPC x j c` | set the justification to center (TODO) | |
| `SPC x j f` | set the justification to full (TODO) | |
| `SPC x j l` | set the justification to left (TODO) | |
| `SPC x j n` | set the justification to none (TODO) | |
| `SPC x j r` | set the justification to right (TODO) | |
| `SPC x J` | move down a line of text (enter transient state) | |
| `SPC x K` | move up a line of text (enter transient state) | |
| `SPC x l d` | duplicate line or region (TODO) | |
| `SPC x l s` | sort lines (TODO) | |
| `SPC x l u` | uniquify lines (TODO) | |
| `SPC x o` | use avy to select a link in the frame and open it (TODO) | |
| `SPC x O` | use avy to select multiple links in the frame and open them (TODO) | |
| `SPC x t c` | swap (transpose) the current character with the previous one | |
| `SPC x t w` | swap (transpose) the current word with the previous one | |
| `SPC x t l` | swap (transpose) the current line with the previous one | |
| `SPC x u` | set the selected text to lower case (TODO) | |
| `SPC x U` | set the selected text to upper case (TODO) | |
| `SPC x w c` | count the number of occurrences per word in the select region (TODO) | |
| `SPC x w d` | show dictionary entry of word from wordnik.com (TODO) | |
| `SPC x TAB` | indent or dedent a region rigidly (TODO) | |
| Key Binding | Description |
| ------------- | -------------------------------------------------------------------- |
| `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 : |
| `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 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 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 |
| `SPC x g l` | set lanuages used by translate commands (TODO) |
| `SPC x g t` | translate current word using Google Translate |
| `SPC x g T` | reverse source and target languages (TODO) |
| `SPC x i c` | change symbol style to `lowerCamelCase` |
| `SPC x i C` | change symbol style to `UpperCamelCase` |
| `SPC x i i` | cycle symbol naming styles (i to keep cycling) |
| `SPC x i -` | change symbol style to `kebab-case` |
| `SPC x i k` | change symbol style to `kebab-case` |
| `SPC x i _` | change symbol style to `under_score` |
| `SPC x i u` | change symbol style to `under_score` |
| `SPC x i U` | change symbol style to `UP_CASE` |
| `SPC x j c` | set the justification to center (TODO) |
| `SPC x j f` | set the justification to full (TODO) |
| `SPC x j l` | set the justification to left (TODO) |
| `SPC x j n` | set the justification to none (TODO) |
| `SPC x j r` | set the justification to right (TODO) |
| `SPC x J` | move down a line of text (enter transient state) |
| `SPC x K` | move up a line of text (enter transient state) |
| `SPC x l d` | duplicate line or region (TODO) |
| `SPC x l s` | sort lines (TODO) |
| `SPC x l u` | uniquify lines (TODO) |
| `SPC x o` | use avy to select a link in the frame and open it (TODO) |
| `SPC x O` | use avy to select multiple links in the frame and open them (TODO) |
| `SPC x t c` | swap (transpose) the current character with the previous one |
| `SPC x t w` | swap (transpose) the current word with the previous one |
| `SPC x t l` | swap (transpose) the current line with the previous one |
| `SPC x u` | set the selected text to lower case (TODO) |
| `SPC x U` | set the selected text to upper case (TODO) |
| `SPC x w c` | count the number of occurrences per word in the select region (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

@ -11,6 +11,7 @@ lang: cn
- [模块简介](#模块简介)
- [功能特性](#功能特性)
- [模块选项](#模块选项)
- [快捷键](#快捷键)
<!-- vim-markdown-toc -->
@ -30,3 +31,26 @@ lang: cn
## 模块选项
- `textobj`: specified a list of text opjects to be enabled, the avaliable list is :`indent`, `line`, `entire`
## 快捷键
快捷键 | 功能描述
--- | ---
`SPC x a {分隔符}` | 基于分隔符进行文本对齐
**默认的分隔符:**
- `=`: 对齐 `===`, `==`, `!=`, `>=`
- `&`: 对齐 `&`
- `¦`: 对齐 `¦`
- `;`: 对齐 `;`
- `:`: 对齐 `:`
- `,`: 对齐 `,`
- `.`: 对齐 `.`
- `[`: 对齐 `[`
- `(`: 对齐 `(`
- `{`: 对齐 `{`
- `]`: 对齐 `]`
- `}`: 对齐 `}`
- `)`: 对齐 `)`

View File

@ -323,7 +323,7 @@ use toml file to add custom forked plugins:
```toml
[[custom_plugins]]
name = 'wsdjeg/neomake.vim'
name = "wsdjeg/neomake.vim"
# note: you need to disable merged feature
merged = false
```
@ -400,7 +400,7 @@ to install it on your system if you wish to use it.
To change the default font set the variable `guifont` in your `~/.SpaceVim.d/init.toml` file. By default its value is:
```toml
guifont = 'DejaVu Sans Mono for Powerline:h11'
guifont = "DejaVu Sans Mono for Powerline:h11"
```
If the specified font is not found, the fallback one will be used (depends on your system).
@ -1558,62 +1558,62 @@ In highlight symbol transient state:
Text related commands (start with `x`):
| Key Binding | Description | |
| ------------- | -------------------------------------------------------------------- | --- |
| `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 : | |
| `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 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 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 | |
| `SPC x g l` | set lanuages used by translate commands (TODO) | |
| `SPC x g t` | translate current word using Google Translate | |
| `SPC x g T` | reverse source and target languages (TODO) | |
| `SPC x i c` | change symbol style to `lowerCamelCase` | |
| `SPC x i C` | change symbol style to `UpperCamelCase` | |
| `SPC x i i` | cycle symbol naming styles (i to keep cycling) | |
| `SPC x i -` | change symbol style to `kebab-case` | |
| `SPC x i k` | change symbol style to `kebab-case` | |
| `SPC x i _` | change symbol style to `under_score` | |
| `SPC x i u` | change symbol style to `under_score` | |
| `SPC x i U` | change symbol style to `UP_CASE` | |
| `SPC x j c` | set the justification to center (TODO) | |
| `SPC x j f` | set the justification to full (TODO) | |
| `SPC x j l` | set the justification to left (TODO) | |
| `SPC x j n` | set the justification to none (TODO) | |
| `SPC x j r` | set the justification to right (TODO) | |
| `SPC x J` | move down a line of text (enter transient state) | |
| `SPC x K` | move up a line of text (enter transient state) | |
| `SPC x l d` | duplicate line or region (TODO) | |
| `SPC x l s` | sort lines (TODO) | |
| `SPC x l u` | uniquify lines (TODO) | |
| `SPC x o` | use avy to select a link in the frame and open it (TODO) | |
| `SPC x O` | use avy to select multiple links in the frame and open them (TODO) | |
| `SPC x t c` | swap (transpose) the current character with the previous one | |
| `SPC x t w` | swap (transpose) the current word with the previous one | |
| `SPC x t l` | swap (transpose) the current line with the previous one | |
| `SPC x u` | set the selected text to lower case (TODO) | |
| `SPC x U` | set the selected text to upper case (TODO) | |
| `SPC x w c` | count the number of occurrences per word in the select region (TODO) | |
| `SPC x w d` | show dictionary entry of word from wordnik.com (TODO) | |
| `SPC x TAB` | indent or dedent a region rigidly (TODO) | |
| Key Binding | Description |
| ------------- | -------------------------------------------------------------------- |
| `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 : |
| `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 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 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 |
| `SPC x g l` | set lanuages used by translate commands (TODO) |
| `SPC x g t` | translate current word using Google Translate |
| `SPC x g T` | reverse source and target languages (TODO) |
| `SPC x i c` | change symbol style to `lowerCamelCase` |
| `SPC x i C` | change symbol style to `UpperCamelCase` |
| `SPC x i i` | cycle symbol naming styles (i to keep cycling) |
| `SPC x i -` | change symbol style to `kebab-case` |
| `SPC x i k` | change symbol style to `kebab-case` |
| `SPC x i _` | change symbol style to `under_score` |
| `SPC x i u` | change symbol style to `under_score` |
| `SPC x i U` | change symbol style to `UP_CASE` |
| `SPC x j c` | set the justification to center (TODO) |
| `SPC x j f` | set the justification to full (TODO) |
| `SPC x j l` | set the justification to left (TODO) |
| `SPC x j n` | set the justification to none (TODO) |
| `SPC x j r` | set the justification to right (TODO) |
| `SPC x J` | move down a line of text (enter transient state) |
| `SPC x K` | move up a line of text (enter transient state) |
| `SPC x l d` | duplicate line or region (TODO) |
| `SPC x l s` | sort lines (TODO) |
| `SPC x l u` | uniquify lines (TODO) |
| `SPC x o` | use avy to select a link in the frame and open it (TODO) |
| `SPC x O` | use avy to select multiple links in the frame and open them (TODO) |
| `SPC x t c` | swap (transpose) the current character with the previous one |
| `SPC x t w` | swap (transpose) the current word with the previous one |
| `SPC x t l` | swap (transpose) the current line with the previous one |
| `SPC x u` | set the selected text to lower case (TODO) |
| `SPC x U` | set the selected text to upper case (TODO) |
| `SPC x w c` | count the number of occurrences per word in the select region (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

View File

@ -10,6 +10,7 @@ description: "Improve code edit expr in SpaceVim, provide more text opjects."
- [Description](#description)
- [Features](#features)
- [Options](#options)
- [Key bindings](#key-bindings)
<!-- vim-markdown-toc -->
@ -29,3 +30,26 @@ This layer provide many edit key bindings for SpaceVim, and also porvide more te
## Options
- `textobj`: specified a list of text opjects to be enabled, the avaliable list is :`indent`, `line`, `entire`
## Key bindings
Key binding | desc
--- | ---
`SPC x a {delimiter}` | align content based on delimiter
**default delimiters**
- `=`: align `===`, `==`, `!=`, `>=` etc.
- `&`: align `&`
- `¦`: align `¦`
- `;`: align `;`
- `:`: align `:`
- `,`: align `,`
- `.`: align `.`
- `[`: align `[`
- `(`: align `(`
- `{`: align `{`
- `]`: align `]`
- `}`: align `}`
- `)`: align `)`