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

Merge pull request #2705 from wsdjeg/iedit-IA

Improve iedit mode
This commit is contained in:
Wang Shidong 2019-03-28 15:35:44 +08:00 committed by GitHub
commit 5e6c76d090
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 75 additions and 54 deletions

View File

@ -17,7 +17,6 @@ function! SpaceVim#layers#edit#plugins() abort
\ ['tpope/vim-surround'],
\ ['tpope/vim-repeat'],
\ ['junegunn/vim-emoji'],
\ ['terryma/vim-multiple-cursors', { 'loadconf' : 1, 'merged' : 0}],
\ ['terryma/vim-expand-region', { 'loadconf' : 1}],
\ ['kana/vim-textobj-user'],
\ ['kana/vim-textobj-indent'],

View File

@ -503,8 +503,10 @@ function! SpaceVim#mapping#space#init() abort
xnoremap <silent> <plug>SpaceVim-plugin-iedit :call SpaceVim#plugins#iedit#start(1)<cr>
call SpaceVim#mapping#space#def('nmap', ['s', 'e'], '<plug>SpaceVim-plugin-iedit',
\ 'start iedit mode', 0, 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'h'], 'call SpaceVim#plugins#highlight#start()',
call SpaceVim#mapping#space#def('nnoremap', ['s', 'H'], 'call SpaceVim#plugins#highlight#start(1)',
\ 'highlight all symbols', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'h'], 'call SpaceVim#plugins#highlight#start(0)',
\ 'highlight current symbols', 1)
" Getting help
let g:_spacevim_mappings_space.h.d = {'name' : '+help-describe'}
call SpaceVim#mapping#space#def('nnoremap', ['h', 'd', 'b'],

View File

@ -110,8 +110,11 @@ function! s:init() abort
endfunction
" }}}
" use SPC s H to highlight all symbol on default range.
" use SPC s h to highlight current symbol on default range.
" public API func: start Highlight mode {{{
function! SpaceVim#plugins#highlight#start() abort
function! SpaceVim#plugins#highlight#start(current) abort
let curpos = getcurpos()
let save_reg_k = @k
normal! viw"ky

View File

@ -149,6 +149,7 @@ endfunction
let s:toggle_stack = {}
" here is a list of normal command which can be handled by idedit
function! s:handle_normal(char) abort
silent! call s:remove_cursor_highlight()
if a:char ==# 105 " i
@ -156,6 +157,16 @@ function! s:handle_normal(char) abort
let w:spacevim_iedit_mode = s:mode
let w:spacevim_statusline_mode = 'ii'
redrawstatus!
elseif a:char == 73 " I
let s:mode = 'i'
let w:spacevim_iedit_mode = s:mode
let w:spacevim_statusline_mode = 'ii'
for i in range(len(s:cursor_stack))
let s:cursor_stack[i].cursor = matchstr(s:cursor_stack[i].begin . s:cursor_stack[i].cursor . s:cursor_stack[i].end, '^.')
let s:cursor_stack[i].end = substitute(s:cursor_stack[i].begin . s:cursor_stack[i].cursor . s:cursor_stack[i].end , '^.', '', 'g')
let s:cursor_stack[i].begin = ''
endfor
redrawstatus!
elseif a:char == 9 " <tab>
if index(keys(s:toggle_stack), s:index . '') == -1
call extend(s:toggle_stack, {s:index : [s:stack[s:index], s:cursor_stack[s:index]]})
@ -176,6 +187,16 @@ function! s:handle_normal(char) abort
let s:cursor_stack[i].end = substitute(s:cursor_stack[i].end, '^.', '', 'g')
endfor
redrawstatus!
elseif a:char == 65 " A
let s:mode = 'i'
let w:spacevim_iedit_mode = s:mode
let w:spacevim_statusline_mode = 'ii'
for i in range(len(s:cursor_stack))
let s:cursor_stack[i].begin = s:cursor_stack[i].begin . s:cursor_stack[i].cursor . s:cursor_stack[i].end
let s:cursor_stack[i].cursor = ''
let s:cursor_stack[i].end = ''
endfor
redrawstatus!
elseif a:char ==# "\<Left>" || a:char == 104
for i in range(len(s:cursor_stack))
if !empty(s:cursor_stack[i].begin)
@ -281,7 +302,11 @@ function! s:handle_insert(char) abort
redraw!
redrawstatus!
return
elseif a:char == 23 " <c-w>
elseif a:char == 23 " ctrl-w : remove last word
for i in range(len(s:cursor_stack))
let s:cursor_stack[i].begin = substitute(s:cursor_stack[i].begin, '\S*\s*$', '', 'g')
endfor
elseif a:char == 21 " Ctrl-u
for i in range(len(s:cursor_stack))
let s:cursor_stack[i].begin = ''
endfor

View File

@ -1,39 +0,0 @@
if g:spacevim_autocomplete_method ==# 'ycm'
function! s:disable_autocomplete() abort
endfunction
function! s:enable_autocomplete() abort
endfunction
elseif g:spacevim_autocomplete_method ==# 'neocomplete'
function! s:disable_autocomplete() abort
NeoCompleteLock
endfunction
function! s:enable_autocomplete() abort
NeoCompleteUnlock
endfunction
elseif g:spacevim_autocomplete_method ==# 'neocomplcache' "{{{
function! s:disable_autocomplete() abort
NeoComplCacheDisable
endfunction
function! s:enable_autocomplete() abort
NeoComplCacheEnable
endfunction
elseif g:spacevim_autocomplete_method ==# 'deoplete'
function! s:disable_autocomplete() abort
call deoplete#disable()
endfunction
function! s:enable_autocomplete() abort
call deoplete#enable()
endfunction
endif
" Called once right before you start selecting multiple cursors
function! Multiple_cursors_before()
call s:disable_autocomplete()
endfunction
" Called once only when the multiple selection is canceled (default <Esc>)
function! Multiple_cursors_after()
call s:enable_autocomplete()
endfunction
" vim:set et sw=2 cc=80:

View File

@ -67,16 +67,17 @@ CONTENTS *SpaceVim-contents*
22. lang#ocaml...............................|SpaceVim-layer-lang-ocaml|
23. lang#php...................................|SpaceVim-layer-lang-php|
24. lang#pony.................................|SpaceVim-layer-lang-pony|
25. lang#puppet.............................|SpaceVim-layer-lang-puppet|
26. lang#python.............................|SpaceVim-layer-lang-python|
27. lang#rust.................................|SpaceVim-layer-lang-rust|
28. lang#scala...............................|SpaceVim-layer-lang-scala|
29. lang#xml...................................|SpaceVim-layer-lang-xml|
30. operator...................................|SpaceVim-layer-operator|
31. shell.........................................|SpaceVim-layer-shell|
32. tmux...........................................|SpaceVim-layer-tmux|
33. tools#dash...............................|SpaceVim-layer-tools-dash|
34. tools#zeal...............................|SpaceVim-layer-tools-zeal|
25. lang#processing.....................|SpaceVim-layer-lang-processing|
26. lang#puppet.............................|SpaceVim-layer-lang-puppet|
27. lang#python.............................|SpaceVim-layer-lang-python|
28. lang#rust.................................|SpaceVim-layer-lang-rust|
29. lang#scala...............................|SpaceVim-layer-lang-scala|
30. lang#xml...................................|SpaceVim-layer-lang-xml|
31. operator...................................|SpaceVim-layer-operator|
32. shell.........................................|SpaceVim-layer-shell|
33. tmux...........................................|SpaceVim-layer-tmux|
34. tools#dash...............................|SpaceVim-layer-tools-dash|
35. tools#zeal...............................|SpaceVim-layer-tools-zeal|
7. API........................................................|SpaceVim-api|
1. cmdlinemenu................................|SpaceVim-api-cmdlinemenu|
2. data#dict....................................|SpaceVim-api-data-dict|
@ -1255,6 +1256,29 @@ Requirements:
==============================================================================
LANG#PONY *SpaceVim-layer-lang-pony*
==============================================================================
LANG#PROCESSING *SpaceVim-layer-lang-processing*
This layer is for Processing development: https://processing.org
This is based on the work from https://github.com/sophacles/vim-processing
Requirements:
1. You will need a copy of processing-java. The best way to do this is to
get a copy of the Processing IDE from https://processing.org/download/
Once you have it, run it, and then select Tools -> install
"processing-java"
MAPPINGS
>
Mode Key Function
-----------------------------------------------
normal SPC l r execute current sketch
<
==============================================================================
LANG#PUPPET *SpaceVim-layer-lang-puppet*

View File

@ -12,6 +12,7 @@ lang: cn
- [功能特性](#功能特性)
- [模块选项](#模块选项)
- [快捷键](#快捷键)
- [多光标支持](#多光标支持)
<!-- vim-markdown-toc -->
@ -40,7 +41,7 @@ lang: cn
| ------------------ | ---------------------- |
| `SPC x a {分隔符}` | 基于分隔符进行文本对齐 |
**默认的分隔符:**
默认的分隔符:
- `=`: 对齐 `===`, `==`, `!=`, `>=`
- `&`: 对齐 `&`
@ -60,6 +61,11 @@ lang: cn
- `o`: 对齐 `+ - * / % ^`
- `r`: 对齐用户输入的正则表达式
### 多光标支持
在 Visual 模式下可使用 Ctrl+n 按键选择下一个匹配位置。此时文档中所有匹配项都会被高亮,选中的匹配位置会有特殊高亮。
可使用 Ctrl+x 按键跳过当前位置。
| 快捷键 | 功能描述 |
| ----------- | ------------------------------------ |
| `SPC x j c` | 居中对齐当前段落 |
@ -70,3 +76,4 @@ lang: cn
| `SPC x u` | 将选中字符串转为小写 |
| `SPC x U` | 将选中字符串转为大写 |
| `SPC x w c` | 统计选中区域的单词数 |