From 1aa36200150cd8744c9c8c3bede9110cbf382c90 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sun, 30 Jun 2024 21:41:09 +0800 Subject: Update --- vim/init/config.vim | 4 ++-- vim/init/keymaps.vim | 43 ++++++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 23 deletions(-) (limited to 'vim/init') diff --git a/vim/init/config.vim b/vim/init/config.vim index 4ec456e..f15c5a8 100644 --- a/vim/init/config.vim +++ b/vim/init/config.vim @@ -154,9 +154,9 @@ augroup InitFileTypesGroup endif endfunction " Edit class and id for javascript files - autocmd FileType html nnoremap cl :call ChangeAttr("class") + autocmd FileType html,markdown nnoremap cl :call ChangeAttr("class") autocmd BufLeave nunmap cl - autocmd FileType html nnoremap id :call ChangeAttr("id") + autocmd FileType html,markdown nnoremap id :call ChangeAttr("id") autocmd BufLeave nunmap id " markdown diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index 68103a1..d0e2cd0 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim @@ -33,8 +33,8 @@ noremap k (v:count == 0 ? 'gk' : 'k') " Search for selected test vnoremap * y/\V=escape(@",'/\') -" Disable highlight when is pressed -map :nohlsearch +" Disable highlight when is pressed +map :noh " Quick move in a line noremap 30h @@ -44,13 +44,13 @@ noremap 30l nnoremap "0p " Fast saving -nmap w :w! +nmap w :w! " Fast quit with error -nmap q :cq +nmap cq :cq " Switch wrap -nmap W :set wrap! +nmap W :set wrap! " Show fold level when it changes nnoremap zm zm:set foldlevel @@ -74,14 +74,15 @@ augroup END " Open terminal " nnoremap , :terminal ++noclose vnoremap , :terminal +echo foo " Toggle paste mode on and off -map pp :setlocal paste! +map pp :setlocal paste! " Switch CDW to root git directory nnoremap cdg :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h')):pwd " Switch CWD to the directory of the open buffer -nnoremap cd :cd %:p:h:pwd +nnoremap cd :cd %:p:h:pwd " Move one line up and down nnoremap ddp @@ -215,8 +216,8 @@ nmap c :tabclose nmap m :tabmove nmap o :tabonly -noremap :call Tab_MoveLeft() -noremap :call Tab_MoveRight() +noremap :call Tab_MoveLeft() +noremap :call Tab_MoveRight() " Let tl toggle between this and the last accessed tab let g:lasttab = 1 @@ -225,7 +226,7 @@ autocmd TabLeave * let g:lasttab = tabpagenr() " Opens a new tab with the current buffer's path " Super useful when editing files in the same directory -map te :tabedit =expand("%:p:h") +map te :tabedit =expand("%:p:h") " Tab move functions function! Tab_MoveLeft() @@ -395,29 +396,29 @@ let g:asyncrun_open = 6 let g:asyncrun_bell = 1 " 设置 F10 打开/关闭 Quickfix 窗口 -nnoremap :call asyncrun#quickfix_toggle(6) +nnoremap :call asyncrun#quickfix_toggle(6) " F9 编译 C/C++ 文件 -nnoremap :AsyncRun gcc -Wall -O2 "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" +nnoremap :AsyncRun gcc -Wall -O2 "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" " F5 运行文件 -nnoremap :call ExecuteFile() +nnoremap :call ExecuteFile() " F7 编译项目 -nnoremap :AsyncRun -cwd= make +nnoremap :AsyncRun -cwd= make " F8 运行项目 -nnoremap :AsyncRun -cwd= -raw make run +nnoremap :AsyncRun -cwd= -raw make run " F6 测试项目 -nnoremap :AsyncRun -cwd= -raw make test +nnoremap :AsyncRun -cwd= -raw make test " 更新 cmake -nnoremap :AsyncRun -cwd= cmake . +nnoremap :AsyncRun -cwd= cmake . " Windows 下支持直接打开新 cmd 窗口运行 if has('win32') || has('win64') - nnoremap :AsyncRun -cwd= -mode=4 make run + nnoremap :AsyncRun -cwd= -mode=4 make run endif @@ -477,15 +478,15 @@ endfunc if executable('rg') noremap :AsyncRun! -cwd= rg -n --no-heading \ --color never -g *.h -g *.c* -g *.py -g *.js -g *.vim - \ "" + \ "" elseif has('win32') || has('win64') noremap :AsyncRun! -cwd= findstr /n /s /C:"" \ "\%CD\%\*.h" "\%CD\%\*.c*" "\%CD\%\*.py" "\%CD\%\*.js" \ "\%CD\%\*.vim" - \ + \ else noremap :AsyncRun! -cwd= grep -n -s -R \ --include='*.h' --include='*.c*' --include='*.py' \ --include='*.js' --include='*.vim' - \ '' + \ '' endif -- cgit v1.2.3-70-g09d2