mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-13 02:05:40 +08:00
Add ~ keybinding for iedit (#3046)
This commit is contained in:
parent
64dc68d796
commit
ad849b6bc6
@ -49,6 +49,20 @@ function! s:self.fill(str, length, ...) abort
|
|||||||
return l:string . l:spaces
|
return l:string . l:spaces
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:self.toggle_case(str) abort
|
||||||
|
let chars = []
|
||||||
|
for char in self.string2chars(a:str)
|
||||||
|
if char2nr(char) >= 97 && char2nr(char) <= 122
|
||||||
|
call add(chars, nr2char(char2nr(char) - 32))
|
||||||
|
elseif char2nr(char) >= 65 && char2nr(char) <= 90
|
||||||
|
call add(chars, nr2char(char2nr(char) + 32))
|
||||||
|
else
|
||||||
|
call add(chars, char)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return join(chars, '')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:self.fill_left(str, length, ...) abort
|
function! s:self.fill_left(str, length, ...) abort
|
||||||
if strwidth(a:str) <= a:length
|
if strwidth(a:str) <= a:length
|
||||||
let l:string = a:str
|
let l:string = a:str
|
||||||
|
@ -221,6 +221,11 @@ function! s:handle_normal(char) abort
|
|||||||
let s:cursor_stack[i].end = ''
|
let s:cursor_stack[i].end = ''
|
||||||
endfor
|
endfor
|
||||||
call s:replace_symbol()
|
call s:replace_symbol()
|
||||||
|
elseif a:char == 126 " ~
|
||||||
|
for i in range(len(s:cursor_stack))
|
||||||
|
let s:cursor_stack[i].cursor = s:STRING.toggle_case(s:cursor_stack[i].cursor)
|
||||||
|
endfor
|
||||||
|
call s:replace_symbol()
|
||||||
elseif a:char == 115 " s
|
elseif a:char == 115 " s
|
||||||
let s:mode = 'i'
|
let s:mode = 'i'
|
||||||
let w:spacevim_iedit_mode = s:mode
|
let w:spacevim_iedit_mode = s:mode
|
||||||
|
@ -40,4 +40,6 @@ Execute ( SpaceVim api: data#string ):
|
|||||||
AssertEqual str.strAllIndex('hello spacevim hello', 'he.*', 1), [[0, 20]]
|
AssertEqual str.strAllIndex('hello spacevim hello', 'he.*', 1), [[0, 20]]
|
||||||
AssertEqual str.strAllIndex('hello spacevim hello', 'he[^ ]*', 1), [[0, 5], [15, 20]]
|
AssertEqual str.strAllIndex('hello spacevim hello', 'he[^ ]*', 1), [[0, 5], [15, 20]]
|
||||||
AssertEqual str.strAllIndex('let s:cursor_stack[i].end = s:cursor_stack[i].cursor . s:cursor_stack[i].end', 's.cursor[^_]*', 1), [[4, 12], [28, 36], [55, 63]]
|
AssertEqual str.strAllIndex('let s:cursor_stack[i].end = s:cursor_stack[i].cursor . s:cursor_stack[i].end', 's.cursor[^_]*', 1), [[4, 12], [28, 36], [55, 63]]
|
||||||
|
Log 'test toggle_case()'
|
||||||
|
AssertEqual str.toggle_case(' A b 123'), ' a B 123'
|
||||||
unlet str
|
unlet str
|
||||||
|
Loading…
x
Reference in New Issue
Block a user