From e68ae5fe812b870acd7792776ab111cf52fb766f Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sat, 29 Jun 2024 00:55:46 +0800 Subject: Update --- vim/init/keymaps.vim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'vim/init') diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index 3c3ebc8..68103a1 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim @@ -11,6 +11,7 @@ " - MANAGE_BUFFERS " - SURROURD_WITH_CHAR " - REDIRECTION_WITH_BUFFER +" - QUICK_SUBSTITUTE " - 终端支持 " - 编译运行 " - 符号搜索 @@ -262,6 +263,7 @@ noremap fm :set foldmethod= let g:lastbuffer = 1 au BufLeave * let g:lastbuffer = bufnr() + "---------------------------------------------------------------------- " SURROURD_WITH_CHAR "---------------------------------------------------------------------- @@ -305,6 +307,26 @@ endfunction command! -nargs=1 -complete=command Redir silent call Redir() nnoremap rr :Redir + +"---------------------------------------------------------------------- +" QUICK_SUBSTITUTE +"---------------------------------------------------------------------- +function! IsSubstituteTextSelected() + execute "norm \" + " Get position of the first/last char + echo col("'<") col("'>") len(getline('.'))+1 + return col("'<") != 1 || col("'>") != len(getline('.')) + 1 +endfunction +function! SelectAreaOrDoSubstitute() + if IsSubstituteTextSelected() + call feedkeys('gv"aygv*NVL') + else + call feedkeys("gv:s//\a/g\\") + endif +endfunction +vnoremap call SelectAreaOrDoSubstitute() + + "---------------------------------------------------------------------- " Markdown items (temproray solution) "---------------------------------------------------------------------- -- cgit v1.2.3-70-g09d2