From bae59d93f4d7056e4b3395132f27a48fa3519ae0 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 10 Jan 2018 22:17:19 +0800 Subject: [PATCH] Add edit mode --- autoload/SpaceVim/layers/core/statusline.vim | 8 ++++++++ autoload/SpaceVim/plugins/iedit.vim | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/core/statusline.vim b/autoload/SpaceVim/layers/core/statusline.vim index 274d3dc2a..3b05d201d 100644 --- a/autoload/SpaceVim/layers/core/statusline.vim +++ b/autoload/SpaceVim/layers/core/statusline.vim @@ -605,7 +605,15 @@ function! SpaceVim#layers#core#statusline#mode(mode) endfunction function! SpaceVim#layers#core#statusline#mode_text(mode) + let iedit_mode = get(w:, 'spacevim_iedit_mode', '') if a:mode == 'n' + if !empty(iedit_mode) + if iedit_mode ==# 'n' + return 'IEDIT-NORMAL ' + else + return 'IEDIT-INSERT ' + endif + endif return 'NORMAL ' elseif a:mode == 'i' return 'INSERT ' diff --git a/autoload/SpaceVim/plugins/iedit.vim b/autoload/SpaceVim/plugins/iedit.vim index 46dfb87bb..900b19d87 100644 --- a/autoload/SpaceVim/plugins/iedit.vim +++ b/autoload/SpaceVim/plugins/iedit.vim @@ -93,6 +93,19 @@ function! s:handle_normal(char) abort let w:spacevim_iedit_mode = s:mode let w:spacevim_statusline_mode = 'ii' redrawstatus! + elseif a:char == 97 + silent! call s:remove_cursor_highlight() + let s:mode = 'i' + let w:spacevim_iedit_mode = s:mode + let w:spacevim_statusline_mode = 'ii' + let s:symbol_begin = s:symbol_begin . s:symbol_cursor + if !empty(s:symbol_cursor) + noautocmd normal! l + endif + let s:symbol_cursor = matchstr(s:symbol_end, '^.') + let s:symbol_end = substitute(s:symbol_end, '^.', '', 'g') + silent! call s:highlight_cursor() + redrawstatus! endif endfunction @@ -102,6 +115,8 @@ function! s:handle_insert(char) abort let s:mode = 'n' let w:spacevim_iedit_mode = s:mode let w:spacevim_statusline_mode = 'in' + silent! call s:highlight_cursor() + redraw! redrawstatus! return elseif a:char == 23 @@ -145,7 +160,7 @@ function! s:replace_symbol(symbol) abort let pos = s:stack[len-1-idx] let line = getline(pos[0]) let begin = line[:pos[1]] - let end = line[pos[1] + pos[2] - 2:] + let end = line[pos[1] + pos[2]:] let line = begin . a:symbol . end call setline(pos[0], line) let s:stack[len-1-idx][2] = len(a:symbol)