From 0bed649a238b300f7b960d52d161cbb0adc717af Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 2 Jul 2024 18:10:23 +0800 Subject: Update --- vim/init/keymaps.vim | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'vim/init') diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index d0e2cd0..e4bdfd4 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim @@ -46,6 +46,9 @@ nnoremap "0p " Fast saving nmap w :w! +" Fast quit with error +nmap q :q + " Fast quit with error nmap cq :cq @@ -74,7 +77,6 @@ augroup END " Open terminal " nnoremap , :terminal ++noclose vnoremap , :terminal -echo foo " Toggle paste mode on and off map pp :setlocal paste! @@ -312,20 +314,17 @@ 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 +let g:text_selected = 1 function! SelectAreaOrDoSubstitute() - if IsSubstituteTextSelected() - call feedkeys('gv"aygv*NVL') + if g:text_selected + call feedkeys("\"sygv/\s\gn") + let g:text_selected = 0 else - call feedkeys("gv:s//\a/g\\") + call feedkeys(":s//\//g\\") + let g:text_selected = 1 endif endfunction -vnoremap call SelectAreaOrDoSubstitute() +vnoremap call SelectAreaOrDoSubstitute() "---------------------------------------------------------------------- -- cgit v1.2.3-70-g09d2