mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 20:00:05 +08:00
Fix and add the key bindings toggle case (#4190)
* Fix the two key bindings 'SPC x u' and 'SPC x U' * Add one new key bindings 'SPC x ~'. * Update the documentations accordingly.
This commit is contained in:
parent
4963cd66ef
commit
7577abceb0
@ -148,8 +148,15 @@ function! SpaceVim#layers#edit#config() abort
|
||||
\ . string(s:_function('s:set_justification_to')) . ', ["right"])',
|
||||
\ 'set-the-justification-to-right', 1)
|
||||
|
||||
call SpaceVim#mapping#space#def('vnoremap', ['x', 'u'], 'gu', 'set the selected text to lower case', 0)
|
||||
call SpaceVim#mapping#space#def('vnoremap', ['x', 'U'], 'gU', 'set the selected text to up case', 0)
|
||||
nnoremap <silent> <Plug>Lowercase :call <SID>toggle_case(0, -1)<Cr>
|
||||
vnoremap <silent> <Plug>Lowercase :call <SID>toggle_case(1, -1)<Cr>
|
||||
nnoremap <silent> <Plug>Uppercase :call <SID>toggle_case(0, 1)<Cr>
|
||||
vnoremap <silent> <Plug>Uppercase :call <SID>toggle_case(1, 1)<Cr>
|
||||
nnoremap <silent> <Plug>ToggleCase :call <SID>toggle_case(0, 0)<Cr>
|
||||
vnoremap <silent> <Plug>ToggleCase :call <SID>toggle_case(1, 0)<Cr>
|
||||
call SpaceVim#mapping#space#def('nmap' , ['x' , 'u'] , '<Plug>Lowercase' , 'lowercase-text' , 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap' , ['x' , 'U'] , '<Plug>Uppercase' , 'uppercase-text' , 0, 1)
|
||||
call SpaceVim#mapping#space#def('nmap' , ['x' , '~'] , '<Plug>ToggleCase' , 'toggle-case-text' , 0, 1)
|
||||
|
||||
" word
|
||||
let g:_spacevim_mappings_space.x.w = {'name' : '+Word'}
|
||||
@ -639,6 +646,26 @@ function! s:uniquify_lines(visual, ignorecase) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:toggle_case(visual, uppercase) abort
|
||||
if a:visual
|
||||
if a:uppercase == 1
|
||||
normal! gvgU
|
||||
elseif a:uppercase == -1
|
||||
normal! gvgu
|
||||
elseif a:uppercase == 0
|
||||
normal! gv~
|
||||
endif
|
||||
else
|
||||
if a:uppercase == 1
|
||||
normal! gUl
|
||||
elseif a:uppercase == -1
|
||||
normal! gul
|
||||
elseif a:uppercase == 0
|
||||
normal! ~
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:insert_stronger_password() abort
|
||||
let save_register = @k
|
||||
let @k = s:PASSWORD.generate_strong(v:count ? v:count : 12)
|
||||
|
@ -1001,8 +1001,9 @@ call SpaceVim#custom#SPC('nnoremap', ['f', 't'], 'echom "hello world"', 'test cu
|
||||
| `SPC x t W` | 交换当前单词和后一个单词的位置 |
|
||||
| `SPC x t l` | 交换当前行和前一行的位置 |
|
||||
| `SPC x t L` | 交换当前行和后一行的位置 |
|
||||
| `SPC x u` | 将选中字符串转为小写 |
|
||||
| `SPC x U` | 将选中字符串转为大写 |
|
||||
| `SPC x u` | 将字符转为小写 |
|
||||
| `SPC x U` | 将字符转为大写 |
|
||||
| `SPC x ~` | 切换字符的大小写 |
|
||||
| `SPC x w c` | 统计选中区域的单词数 |
|
||||
| `SPC x w d` | show dictionary entry of word from wordnik.com (TODO) |
|
||||
| `SPC x <Tab>` | indent or dedent a region rigidly (TODO) |
|
||||
|
@ -1074,8 +1074,9 @@ Text related commands (start with `x`):
|
||||
| `SPC x t W` | swap (transpose) the current word with the next one |
|
||||
| `SPC x t l` | swap (transpose) the current line with the previous one |
|
||||
| `SPC x t L` | swap (transpose) the current line with the next one |
|
||||
| `SPC x u` | set the selected text to lower case |
|
||||
| `SPC x U` | set the selected text to upper case |
|
||||
| `SPC x u` | lowercase text |
|
||||
| `SPC x U` | uppercase text |
|
||||
| `SPC x ~` | toggle case text |
|
||||
| `SPC x w c` | count the words in the select region |
|
||||
| `SPC x w d` | show dictionary entry of word from wordnik.com (TODO) |
|
||||
| `SPC x <Tab>` | indent or dedent a region rigidly (TODO) |
|
||||
|
Loading…
Reference in New Issue
Block a user