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

feat(iedit): add b key binding for iedit

This commit is contained in:
wsdjeg 2022-03-23 19:41:06 +08:00
parent c542da7606
commit c8cc8c0332
2 changed files with 14 additions and 0 deletions

View File

@ -23,6 +23,7 @@
" Iedit-Normal a start iedit-insert mode after cursor " Iedit-Normal a start iedit-insert mode after cursor
" Iedit-Normal e forward to the end of word " Iedit-Normal e forward to the end of word
" Iedit-Normal w forward to the begin of next word " Iedit-Normal w forward to the begin of next word
" Iedit-Normal b move to the begin of current word
" < " <
let s:stack = [] let s:stack = []
@ -341,6 +342,18 @@ function! s:handle_normal(char) abort
let s:cursor_stack[i].begin = substitute(s:cursor_stack[i].begin, '.$', '', 'g') let s:cursor_stack[i].begin = substitute(s:cursor_stack[i].begin, '.$', '', 'g')
let s:cursor_stack[i].end = substitute(s:cursor_stack[i].end, '^\s*\S*', '', 'g') let s:cursor_stack[i].end = substitute(s:cursor_stack[i].end, '^\s*\S*', '', 'g')
endfor endfor
elseif a:char ==# 'b'
" b: move to the begin of current word
for i in range(len(s:cursor_stack))
let word = matchstr(s:cursor_stack[i].begin, '\S*\s*$')
let s:cursor_stack[i].end =
\ word
\ . s:cursor_stack[i].cursor
\ . s:cursor_stack[i].end
let s:cursor_stack[i].begin = substitute(s:cursor_stack[i].begin, '\S*\s*$', '', 'g')
let s:cursor_stack[i].cursor = matchstr(s:cursor_stack[i].end, '^.')
let s:cursor_stack[i].end = substitute(s:cursor_stack[i].end, '^.', '', 'g')
endfor
elseif a:char ==# 'w' elseif a:char ==# 'w'
for i in range(len(s:cursor_stack)) for i in range(len(s:cursor_stack))
let word = matchstr(s:cursor_stack[i].end, '^\S*\s*') let word = matchstr(s:cursor_stack[i].end, '^\S*\s*')

View File

@ -5432,6 +5432,7 @@ After starting iedit, the following key bindings can be used:
Iedit-Normal a start iedit-insert mode after cursor Iedit-Normal a start iedit-insert mode after cursor
Iedit-Normal e forward to the end of word Iedit-Normal e forward to the end of word
Iedit-Normal w forward to the begin of next word Iedit-Normal w forward to the begin of next word
Iedit-Normal b move to the begin of current word
< <
============================================================================== ==============================================================================