1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 02:30:03 +08:00

Add f{char} for iedit-normal mode (#3922)

This commit is contained in:
Wang Shidong 2020-10-23 22:41:54 +08:00 committed by GitHub
parent 7f2a7cc57c
commit ce73df6fc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 2 deletions

View File

@ -140,13 +140,31 @@ endfunction
function! s:handle(mode, char) abort
if a:mode ==# 'n'
if a:mode ==# 'n' && s:Operator ==# 'f'
return s:handle_f_char(a:char)
elseif a:mode ==# 'n'
return s:handle_normal(a:char)
elseif a:mode ==# 'i'
return s:handle_insert(a:char)
endif
endfunction
function! s:handle_f_char(char) abort
silent! call s:remove_cursor_highlight()
" map(rang(32,126), 'nr2char(v:val)')
" [' ', '!', '"', '#', '$', '%', '&', '''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~']
if a:char >= 32 && a:char <= 126
let s:Operator = ''
for i in range(len(s:cursor_stack))
let matchedstr = matchstr(s:cursor_stack[i].end, printf('[^%s]*', nr2char(a:char)))
let s:cursor_stack[i].begin = s:cursor_stack[i].begin . s:cursor_stack[i].cursor . matchedstr
let s:cursor_stack[i].end = matchstr(s:cursor_stack[i].end, printf('[%s]\zs.*', nr2char(a:char)))
let s:cursor_stack[i].cursor = nr2char(a:char)
endfor
endif
silent! call s:highlight_cursor()
return s:cursor_stack[0].begin . s:cursor_stack[0].cursor . s:cursor_stack[0].end
endfunction
let s:toggle_stack = {}
@ -227,6 +245,9 @@ function! s:handle_normal(char) abort
let s:cursor_stack[i].cursor = s:STRING.toggle_case(s:cursor_stack[i].cursor)
endfor
call s:replace_symbol()
elseif a:char == 102 " f
let s:Operator = 'f'
call s:timeout()
elseif a:char == 115 " s
let s:mode = 'i'
let w:spacevim_iedit_mode = s:mode

View File

@ -1819,7 +1819,7 @@ Denite/Unite 是一个强大的信息筛选浏览器,这类似于 Emacs 中的
| `SPC p k` | 关闭当前工程的所有缓冲区 |
| `SPC p p` | 显示所有工程 |
`SPC p p` 将会列出最近使用的项目清单默认会显示最多20个
`SPC p p` 将会列出最近使用的项目清单,默认会显示最多 20 个,
这一数量可以使用 `projects_cache_num` 来修改。
为了可以夸 Vim 进程读取历史打开的项目信息,这一功能使用了缓存机制。
@ -2044,6 +2044,7 @@ SpaceVim 内置了 iedit 多光标模式,可快速进行多光标编辑。这
| `X` | 删除所有 occurrences 中光标前的字符,类似于一般模式下的 `X` |
| `gg` | 跳至第一个 occurrence类似于一般模式下的 `gg` |
| `G` | 跳至最后一个 occurrence类似于一般模式下的 `G` |
| `f{char}` | 向右移动光标至字符 `{char}` 首次出现的位置 |
| `n` | 跳至下一个 occurrence |
| `N` | 跳至上一个 occurrence |
| `p` | 替换所有 occurrences 为最后复制的文本 |

View File

@ -2098,6 +2098,7 @@ The default color for iedit is `red`/`green` which is based on the current color
| `X` | delete the character before cursor in all the occurrences, same as `X` in `Normal` model |
| `gg` | go to first occurrence, same as `gg` in `Normal` model |
| `G` | go to last occurrence, same as `G` in `Normal` model |
| `f{char}` | Move the cursor to the right where the `{char}` first appears in all the occurrences |
| `n` | go to next occurrence |
| `N` | go to previous occurrence |
| `p` | replace occurrences with last yanked (copied) text |