aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim/init/keymaps.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/init/keymaps.vim')
-rw-r--r--vim/init/keymaps.vim43
1 files changed, 22 insertions, 21 deletions
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
34vnoremap * y/\V<C-R>=escape(@",'/\')<CR><CR> 34vnoremap * 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
37map <silent> <leader><cr> :nohlsearch<cr> 37map <silent> <leader><CR> :noh<CR>
38 38
39" Quick move in a line 39" Quick move in a line
40noremap <C-h> 30h 40noremap <C-h> 30h
@@ -44,13 +44,13 @@ noremap <C-l> 30l
44nnoremap <C-p> "0p 44nnoremap <C-p> "0p
45 45
46" Fast saving 46" Fast saving
47nmap <leader>w :w!<cr> 47nmap <leader>w :w!<CR>
48 48
49" Fast quit with error 49" Fast quit with error
50nmap <leader>q :cq<cr> 50nmap cq :cq<CR>
51 51
52" Switch wrap 52" Switch wrap
53nmap <leader>W :set wrap!<cr> 53nmap <leader>W :set wrap!<CR>
54 54
55" Show fold level when it changes 55" Show fold level when it changes
56nnoremap zm zm:set foldlevel<CR> 56nnoremap 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>
76vnoremap <leader>, :terminal<CR> 76vnoremap <leader>, :terminal<CR>
77echo foo
77 78
78" Toggle paste mode on and off 79" Toggle paste mode on and off
79map <leader>pp :setlocal paste!<cr> 80map <leader>pp :setlocal paste!<CR>
80 81
81" Switch CDW to root git directory 82" Switch CDW to root git directory
82nnoremap cdg :execute 'cd' fnameescape(fnamemodify(finddir('.git', escape(expand('%:p:h'), ' ') . ';'), ':h'))<CR>:pwd<CR> 83nnoremap 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
84nnoremap cd :cd %:p:h<cr>:pwd<cr> 85nnoremap cd :cd %:p:h<CR>:pwd<CR>
85 86
86" Move one line up and down 87" Move one line up and down
87nnoremap <C-j> ddp 88nnoremap <C-j> ddp
@@ -215,8 +216,8 @@ nmap <C-t>c :tabclose<CR>
215nmap <C-t>m :tabmove 216nmap <C-t>m :tabmove
216nmap <C-t>o :tabonly 217nmap <C-t>o :tabonly
217 218
218noremap <silent><m-h> :call Tab_MoveLeft()<cr> 219noremap <silent><m-h> :call Tab_MoveLeft()<CR>
219noremap <silent><m-l> :call Tab_MoveRight()<cr> 220noremap <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
222let g:lasttab = 1 223let 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
228map <leader>te :tabedit <C-r>=expand("%:p:h")<cr> 229map <leader>te :tabedit <C-r>=expand("%:p:h")<CR>
229 230
230" Tab move functions 231" Tab move functions
231function! Tab_MoveLeft() 232function! Tab_MoveLeft()
@@ -395,29 +396,29 @@ let g:asyncrun_open = 6
395let g:asyncrun_bell = 1 396let g:asyncrun_bell = 1
396 397
397" 设置 F10 打开/关闭 Quickfix 窗口 398" 设置 F10 打开/关闭 Quickfix 窗口
398nnoremap <F10> :call asyncrun#quickfix_toggle(6)<cr> 399nnoremap <F10> :call asyncrun#quickfix_toggle(6)<CR>
399 400
400" F9 编译 C/C++ 文件 401" F9 编译 C/C++ 文件
401nnoremap <silent> <F9> :AsyncRun gcc -Wall -O2 "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" <cr> 402nnoremap <silent> <F9> :AsyncRun gcc -Wall -O2 "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" <CR>
402 403
403" F5 运行文件 404" F5 运行文件
404nnoremap <silent> <F5> :call ExecuteFile()<cr> 405nnoremap <silent> <F5> :call ExecuteFile()<CR>
405 406
406" F7 编译项目 407" F7 编译项目
407nnoremap <silent> <F7> :AsyncRun -cwd=<root> make <cr> 408nnoremap <silent> <F7> :AsyncRun -cwd=<root> make <CR>
408 409
409" F8 运行项目 410" F8 运行项目
410nnoremap <silent> <F8> :AsyncRun -cwd=<root> -raw make run <cr> 411nnoremap <silent> <F8> :AsyncRun -cwd=<root> -raw make run <CR>
411 412
412" F6 测试项目 413" F6 测试项目
413nnoremap <silent> <F6> :AsyncRun -cwd=<root> -raw make test <cr> 414nnoremap <silent> <F6> :AsyncRun -cwd=<root> -raw make test <CR>
414 415
415" 更新 cmake 416" 更新 cmake
416nnoremap <silent> <F4> :AsyncRun -cwd=<root> cmake . <cr> 417nnoremap <silent> <F4> :AsyncRun -cwd=<root> cmake . <CR>
417 418
418" Windows 下支持直接打开新 cmd 窗口运行 419" Windows 下支持直接打开新 cmd 窗口运行
419if has('win32') || has('win64') 420if 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>
421endif 422endif
422 423
423 424
@@ -477,15 +478,15 @@ endfunc
477if executable('rg') 478if 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>
481elseif has('win32') || has('win64') 482elseif 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>
486else 487else
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>
491endif 492endif