diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-06-30 21:41:09 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-06-30 21:41:09 +0800 |
commit | 1aa36200150cd8744c9c8c3bede9110cbf382c90 (patch) | |
tree | e16447fb052a3599de3ce899d3ff9d6b140cb27b /vim | |
parent | e68ae5fe812b870acd7792776ab111cf52fb766f (diff) |
Update
Diffstat (limited to 'vim')
-rw-r--r-- | vim/init/config.vim | 4 | ||||
-rw-r--r-- | vim/init/keymaps.vim | 43 |
2 files changed, 24 insertions, 23 deletions
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 | |||
154 | endif | 154 | endif |
155 | endfunction | 155 | endfunction |
156 | " Edit class and id for javascript files | 156 | " Edit class and id for javascript files |
157 | autocmd FileType html nnoremap <leader>cl :call <SID>ChangeAttr("class")<CR> | 157 | autocmd FileType html,markdown nnoremap <leader>cl :call <SID>ChangeAttr("class")<CR> |
158 | autocmd BufLeave nunmap <leader>cl | 158 | autocmd BufLeave nunmap <leader>cl |
159 | autocmd FileType html nnoremap <leader>id :call <SID>ChangeAttr("id")<CR> | 159 | autocmd FileType html,markdown nnoremap <leader>id :call <SID>ChangeAttr("id")<CR> |
160 | autocmd BufLeave nunmap <leader>id | 160 | autocmd BufLeave nunmap <leader>id |
161 | 161 | ||
162 | " markdown | 162 | " 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 <silent> <expr> k (v:count == 0 ? 'gk' : 'k') | |||
33 | " Search for selected test | 33 | " Search for selected test |
34 | vnoremap * y/\V<C-R>=escape(@",'/\')<CR><CR> | 34 | vnoremap * y/\V<C-R>=escape(@",'/\')<CR><CR> |
35 | 35 | ||
36 | " Disable highlight when <leader><cr> is pressed | 36 | " Disable highlight when <leader><CR> is pressed |
37 | map <silent> <leader><cr> :nohlsearch<cr> | 37 | map <silent> <leader><CR> :noh<CR> |
38 | 38 | ||
39 | " Quick move in a line | 39 | " Quick move in a line |
40 | noremap <C-h> 30h | 40 | noremap <C-h> 30h |
@@ -44,13 +44,13 @@ noremap <C-l> 30l | |||
44 | nnoremap <C-p> "0p | 44 | nnoremap <C-p> "0p |
45 | 45 | ||
46 | " Fast saving | 46 | " Fast saving |
47 | nmap <leader>w :w!<cr> | 47 | nmap <leader>w :w!<CR> |
48 | 48 | ||
49 | " Fast quit with error | 49 | " Fast quit with error |
50 | nmap <leader>q :cq<cr> | 50 | nmap cq :cq<CR> |
51 | 51 | ||
52 | " Switch wrap | 52 | " Switch wrap |
53 | nmap <leader>W :set wrap!<cr> | 53 | nmap <leader>W :set wrap!<CR> |
54 | 54 | ||
55 | " Show fold level when it changes | 55 | " Show fold level when it changes |
56 | nnoremap zm zm:set foldlevel<CR> | 56 | nnoremap zm zm:set foldlevel<CR> |
@@ -74,14 +74,15 @@ augroup END | |||
74 | " Open terminal | 74 | " Open terminal |
75 | " nnoremap <leader>, :terminal ++noclose<CR> | 75 | " nnoremap <leader>, :terminal ++noclose<CR> |
76 | vnoremap <leader>, :terminal<CR> | 76 | vnoremap <leader>, :terminal<CR> |
77 | echo foo | ||
77 | 78 | ||
78 | " Toggle paste mode on and off | 79 | " Toggle paste mode on and off |
79 | map <leader>pp :setlocal paste!<cr> | 80 | map <leader>pp :setlocal paste!<CR> |
80 | 81 | ||
81 | " Switch CDW to root git directory | 82 | " Switch CDW to root git directory |
82 | nnoremap cdg :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h'))<CR>:pwd<CR> | 83 | nnoremap cdg :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h'))<CR>:pwd<CR> |
83 | " Switch CWD to the directory of the open buffer | 84 | " Switch CWD to the directory of the open buffer |
84 | nnoremap cd :cd %:p:h<cr>:pwd<cr> | 85 | nnoremap cd :cd %:p:h<CR>:pwd<CR> |
85 | 86 | ||
86 | " Move one line up and down | 87 | " Move one line up and down |
87 | nnoremap <C-j> ddp | 88 | nnoremap <C-j> ddp |
@@ -215,8 +216,8 @@ nmap <C-t>c :tabclose<CR> | |||
215 | nmap <C-t>m :tabmove | 216 | nmap <C-t>m :tabmove |
216 | nmap <C-t>o :tabonly | 217 | nmap <C-t>o :tabonly |
217 | 218 | ||
218 | noremap <silent><m-h> :call Tab_MoveLeft()<cr> | 219 | noremap <silent><m-h> :call Tab_MoveLeft()<CR> |
219 | noremap <silent><m-l> :call Tab_MoveRight()<cr> | 220 | noremap <silent><m-l> :call Tab_MoveRight()<CR> |
220 | 221 | ||
221 | " Let <leader>tl toggle between this and the last accessed tab | 222 | " Let <leader>tl toggle between this and the last accessed tab |
222 | let g:lasttab = 1 | 223 | let g:lasttab = 1 |
@@ -225,7 +226,7 @@ autocmd TabLeave * let g:lasttab = tabpagenr() | |||
225 | 226 | ||
226 | " Opens a new tab with the current buffer's path | 227 | " Opens a new tab with the current buffer's path |
227 | " Super useful when editing files in the same directory | 228 | " Super useful when editing files in the same directory |
228 | map <leader>te :tabedit <C-r>=expand("%:p:h")<cr> | 229 | map <leader>te :tabedit <C-r>=expand("%:p:h")<CR> |
229 | 230 | ||
230 | " Tab move functions | 231 | " Tab move functions |
231 | function! Tab_MoveLeft() | 232 | function! Tab_MoveLeft() |
@@ -395,29 +396,29 @@ let g:asyncrun_open = 6 | |||
395 | let g:asyncrun_bell = 1 | 396 | let g:asyncrun_bell = 1 |
396 | 397 | ||
397 | " 设置 F10 打开/关闭 Quickfix 窗口 | 398 | " 设置 F10 打开/关闭 Quickfix 窗口 |
398 | nnoremap <F10> :call asyncrun#quickfix_toggle(6)<cr> | 399 | nnoremap <F10> :call asyncrun#quickfix_toggle(6)<CR> |
399 | 400 | ||
400 | " F9 编译 C/C++ 文件 | 401 | " F9 编译 C/C++ 文件 |
401 | nnoremap <silent> <F9> :AsyncRun gcc -Wall -O2 "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" <cr> | 402 | nnoremap <silent> <F9> :AsyncRun gcc -Wall -O2 "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" <CR> |
402 | 403 | ||
403 | " F5 运行文件 | 404 | " F5 运行文件 |
404 | nnoremap <silent> <F5> :call ExecuteFile()<cr> | 405 | nnoremap <silent> <F5> :call ExecuteFile()<CR> |
405 | 406 | ||
406 | " F7 编译项目 | 407 | " F7 编译项目 |
407 | nnoremap <silent> <F7> :AsyncRun -cwd=<root> make <cr> | 408 | nnoremap <silent> <F7> :AsyncRun -cwd=<root> make <CR> |
408 | 409 | ||
409 | " F8 运行项目 | 410 | " F8 运行项目 |
410 | nnoremap <silent> <F8> :AsyncRun -cwd=<root> -raw make run <cr> | 411 | nnoremap <silent> <F8> :AsyncRun -cwd=<root> -raw make run <CR> |
411 | 412 | ||
412 | " F6 测试项目 | 413 | " F6 测试项目 |
413 | nnoremap <silent> <F6> :AsyncRun -cwd=<root> -raw make test <cr> | 414 | nnoremap <silent> <F6> :AsyncRun -cwd=<root> -raw make test <CR> |
414 | 415 | ||
415 | " 更新 cmake | 416 | " 更新 cmake |
416 | nnoremap <silent> <F4> :AsyncRun -cwd=<root> cmake . <cr> | 417 | nnoremap <silent> <F4> :AsyncRun -cwd=<root> cmake . <CR> |
417 | 418 | ||
418 | " Windows 下支持直接打开新 cmd 窗口运行 | 419 | " Windows 下支持直接打开新 cmd 窗口运行 |
419 | if has('win32') || has('win64') | 420 | if has('win32') || has('win64') |
420 | nnoremap <silent> <F8> :AsyncRun -cwd=<root> -mode=4 make run <cr> | 421 | nnoremap <silent> <F8> :AsyncRun -cwd=<root> -mode=4 make run <CR> |
421 | endif | 422 | endif |
422 | 423 | ||
423 | 424 | ||
@@ -477,15 +478,15 @@ endfunc | |||
477 | if executable('rg') | 478 | if executable('rg') |
478 | noremap <silent><F2> :AsyncRun! -cwd=<root> rg -n --no-heading | 479 | noremap <silent><F2> :AsyncRun! -cwd=<root> rg -n --no-heading |
479 | \ --color never -g *.h -g *.c* -g *.py -g *.js -g *.vim | 480 | \ --color never -g *.h -g *.c* -g *.py -g *.js -g *.vim |
480 | \ <C-R><C-W> "<root>" <cr> | 481 | \ <C-R><C-W> "<root>" <CR> |
481 | elseif has('win32') || has('win64') | 482 | elseif has('win32') || has('win64') |
482 | noremap <silent><F2> :AsyncRun! -cwd=<root> findstr /n /s /C:"<C-R><C-W>" | 483 | noremap <silent><F2> :AsyncRun! -cwd=<root> findstr /n /s /C:"<C-R><C-W>" |
483 | \ "\%CD\%\*.h" "\%CD\%\*.c*" "\%CD\%\*.py" "\%CD\%\*.js" | 484 | \ "\%CD\%\*.h" "\%CD\%\*.c*" "\%CD\%\*.py" "\%CD\%\*.js" |
484 | \ "\%CD\%\*.vim" | 485 | \ "\%CD\%\*.vim" |
485 | \ <cr> | 486 | \ <CR> |
486 | else | 487 | else |
487 | noremap <silent><F2> :AsyncRun! -cwd=<root> grep -n -s -R <C-R><C-W> | 488 | noremap <silent><F2> :AsyncRun! -cwd=<root> grep -n -s -R <C-R><C-W> |
488 | \ --include='*.h' --include='*.c*' --include='*.py' | 489 | \ --include='*.h' --include='*.c*' --include='*.py' |
489 | \ --include='*.js' --include='*.vim' | 490 | \ --include='*.js' --include='*.vim' |
490 | \ '<root>' <cr> | 491 | \ '<root>' <CR> |
491 | endif | 492 | endif |