"====================================================================== " " keymaps.vim - keymaps starting with " " Created by skywind on 2016/10/12 " Last Modified: 2023/09/18 02:35 " "====================================================================== "---------------------------------------------------------------------- " tab switching "---------------------------------------------------------------------- let s:array = [')', '!', '@', '#', '$', '%', '^', '&', '*', '('] for i in range(10) let x = (i == 0)? 10 : i let c = s:array[i] exec "noremap ".x."gt" exec "inoremap ".x."gt" if get(g:, 'vim_no_meta_shift_num', 0) == 0 exec "noremap ".x."gt" exec "inoremap ".x."gt" endif endfor noremap :tabnew inoremap :tabnew noremap :tabclose inoremap :tabclose noremap :w inoremap :w "---------------------------------------------------------------------- " VimTools "---------------------------------------------------------------------- for s:index in range(10) let s:button = (s:index > 0)? 'F'.s:index : 'F10' if has('gui_running') exec "noremap :AsyncTask task-c-f".s:index . '' exec "inoremap :AsyncTask task-c-f".s:index . '' endif endfor "---------------------------------------------------------------------- " window "---------------------------------------------------------------------- nnoremap = :resize +3 nnoremap - :resize -3 nnoremap , :vertical resize -3 nnoremap . :vertical resize +3 nnoremap hh :nohl nnoremap :nohl:redraw! nnoremap , :call Tab_MoveLeft() nnoremap . :call Tab_MoveRight() nnoremap 6 :VinegarOpen leftabove vs nnoremap 7 :VinegarOpen vs nnoremap 8 :VinegarOpen belowright sp nnoremap 9 :VinegarOpen tabedit nnoremap 0 :exe "NERDTree ".fnameescape(expand("%:p:h")) nnoremap y :exe "NERDTree ".fnameescape(asclib#path#get_root("%")) nnoremap g p " nnoremap ha :GuiSignRemove " \ errormarker_error errormarker_warning " replace nnoremap p viw"0p nnoremap y yiw " fast save nnoremap :w inoremap :w nnoremap :tabnew vnoremap :tabnew inoremap :tabnew nnoremap :tabclose inoremap :tabclose nnoremap :close inoremap :close nnoremap :w inoremap :w "---------------------------------------------------------------------- " Movement Enhancement "---------------------------------------------------------------------- noremap b noremap w noremap gj noremap gk inoremap inoremap inoremap gj inoremap gk inoremap d$ cnoremap cnoremap cnoremap cnoremap "---------------------------------------------------------------------- " fast window switching: ALT+SHIFT+HJKL "---------------------------------------------------------------------- noremap h noremap l noremap j noremap k inoremap h inoremap l inoremap j inoremap k if has('terminal') && exists(':terminal') == 2 && has('patch-8.1.1') set termwinkey= tnoremap h tnoremap l tnoremap j tnoremap k tnoremap tnoremap 1gt tnoremap 2gt tnoremap 3gt tnoremap 4gt tnoremap 5gt tnoremap 6gt tnoremap 7gt tnoremap 8gt tnoremap 9gt tnoremap 10gt elseif has('nvim') tnoremap h tnoremap l tnoremap j tnoremap k tnoremap tnoremap 1gt tnoremap 2gt tnoremap 3gt tnoremap 4gt tnoremap 5gt tnoremap 6gt tnoremap 7gt tnoremap 8gt tnoremap 9gt tnoremap 10gt endif "---------------------------------------------------------------------- " GUI hotkeys "---------------------------------------------------------------------- if has('gui_running') || (has('nvim') && (has('win32') || has('win64'))) noremap :call Open_Browse(2) inoremap :call Open_Browse(2) noremap o noremap O noremap :call Tab_MoveLeft() noremap :call Tab_MoveRight() inoremap :call Tab_MoveLeft() inoremap :call Tab_MoveRight() if v:version >= 802 tnoremap :call Tab_MoveLeft() tnoremap :call Tab_MoveRight() endif if has('gui_macvim') noremap :call Toggle_Transparency(9) else noremap :call Toggle_Transparency(15) endif endif if has('gui_running') || has('gui_macvim') || has('gui_mac') " new digraph inoremap inoremap endif nnoremap za nnoremap zA "---------------------------------------------------------------------- " terminal "---------------------------------------------------------------------- if has('terminal') " tnoremap N endif " editing commands nnoremap aa ggVG "---------------------------------------------------------------------- " text-objects "---------------------------------------------------------------------- onoremap az :normal! ggVG vnoremap az ogg0oG$ " onoremap il :normal! v$o^oh " vnoremap il $o^oh vnoremap ik 0o$h onoremap ik :normal vik vnoremap ak 0o$ onoremap ak :normal vak "---------------------------------------------------------------------- " tasks "---------------------------------------------------------------------- noremap :AsyncTaskEdit inoremap :AsyncTaskEdit noremap :TaskFinder inoremap :TaskFinder noremap :AsyncTaskEnviron profile debug release static inoremap :AsyncTaskEnviron profile debug release static noremap :AsyncTask file-run noremap :AsyncTask make noremap :AsyncTask emake noremap :AsyncTask emake-exe noremap :AsyncTask file-build noremap :call asyncrun#quickfix_toggle(6) noremap :AsyncTask file-debug noremap :AsyncTask project-run noremap :AsyncTask project-test noremap :AsyncTask project-init noremap :AsyncTask project-install noremap :AsyncTask project-build noremap :AsyncTask project-debug inoremap :AsyncTask file-run inoremap :AsyncTask make inoremap :AsyncTask emake inoremap :AsyncTask emake-exe inoremap :AsyncTask file-build inoremap :call asyncrun#quickfix_toggle(6) inoremap :AsyncTask project-run inoremap :AsyncTask project-test inoremap :AsyncTask project-init inoremap :AsyncTask project-install inoremap :AsyncTask project-build noremap :AsyncTask task-f1 noremap :AsyncTask task-f2 noremap :AsyncTask task-f3 noremap :AsyncTask task-f4 noremap :AsyncTask task-s-f1 noremap :AsyncTask task-s-f2 noremap :AsyncTask task-s-f3 noremap :AsyncTask task-s-f4 inoremap :AsyncTask task-f1 inoremap :AsyncTask task-f2 inoremap :AsyncTask task-f3 inoremap :AsyncTask task-f4 inoremap :AsyncTask task-s-f1 inoremap :AsyncTask task-s-f2 inoremap :AsyncTask task-s-f3 inoremap :AsyncTask task-s-f4 "---------------------------------------------------------------------- "- quickui buffer switch / bufferhint "---------------------------------------------------------------------- if has('patch-8.2.1') || has('nvim-0.4') nnoremap + :call quickui#tools#list_buffer('FileSwitch tabe') else nnoremap + :call bufferhint#Popup() endif "---------------------------------------------------------------------- " space + j : make "---------------------------------------------------------------------- nnoremap jj :AsyncRun -cwd= make nnoremap jc :AsyncRun -cwd= make clean nnoremap jk :AsyncRun -mode=4 -cwd= make run nnoremap jl :AsyncRun -mode=4 -cwd= make test nnoremap j1 :AsyncRun -mode=4 -cwd= make t1 nnoremap j2 :AsyncRun -mode=4 -cwd= make t2 nnoremap j3 :AsyncRun -mode=4 -cwd= make t3 nnoremap j4 :AsyncRun -mode=4 -cwd= make t4 nnoremap j5 :AsyncRun -mode=4 -cwd= make t5 nnoremap k1 :AsyncRun -cwd= make t1 nnoremap k2 :AsyncRun -cwd= make t2 nnoremap k3 :AsyncRun -cwd= make t3 nnoremap k4 :AsyncRun -cwd= make t4 nnoremap k5 :AsyncRun -cwd= make t5 nnoremap jm :call Tools_SwitchMakeFile() "---------------------------------------------------------------------- " set keymap to GrepCode "---------------------------------------------------------------------- nnoremap cq :VimStop nnoremap cQ :VimStop! nnoremap cv :GrepCode =expand("") nnoremap cx :GrepCode! =expand("") "---------------------------------------------------------------------- " cscope "---------------------------------------------------------------------- if has("cscope") noremap cs :VimScope s noremap cg :VimScope g noremap cc :VimScope c noremap ct :VimScope t noremap ce :VimScope e noremap cd :VimScope d noremap ca :VimScope a noremap cf :VimScope f noremap ci :VimScope i if v:version >= 800 || has('patch-7.4.2038') set cscopequickfix=s+,c+,d+,i+,t+,e+,g+,f+,a+ else set cscopequickfix=s+,c+,d+,i+,t+,e+,g+,f+ endif endif nnoremap cb1 :call vimmake#update_tags('', 'ctags', '.tags') nnoremap cb2 :call vimmake#update_tags('', 'cs', '.cscope') nnoremap cb3 :call vimmake#update_tags('!', 'ctags', '.tags') nnoremap cb4 :call vimmake#update_tags('!', 'cs', '.cscope') nnoremap cb5 :call vimmake#update_tags('', 'py', '.cscopy') nnoremap cb6 :call vimmake#update_tags('!', 'py', '.cscopy') "---------------------------------------------------------------------- " space + t : toggle plugins "---------------------------------------------------------------------- "noremap :call Toggle_Taglist() "inoremap :call Toggle_Taglist() noremap :call quickmenu#toggle(0) inoremap :call quickmenu#toggle(0) noremap :call quickui#tools#preview_tag('') noremap :PreviewClose nnoremap ; :PreviewGoto edit nnoremap : :PreviewGoto tabe if has('autocmd') function! s:insert_enter() if get(g:, 'echodoc#enable_at_startup', 0) != 0 set noshowmode elseif exists(':CocInstall') || exists(':LspDiagNextWrap') set noshowmode endif endfunc function! s:insert_leave() if get(g:, 'echodoc#enable_at_startup', 0) != 0 set showmode elseif exists(':CocInstall') || exists(':LspDiagNextWrap') set showmode endif endfunc augroup AscKeymapsAu autocmd! autocmd InsertLeave * call s:insert_leave() autocmd InsertEnter * call s:insert_enter() " autocmd InsertLeave * set showmode if exists('##TerminalOpen') autocmd TerminalOpen * setlocal ft=terminal elseif exists('##TermOpen') autocmd TermOpen * setlocal ft=terminal endif augroup END endif nnoremap :PreviewSignature inoremap :PreviewSignature "---------------------------------------------------------------------- " GUI/Terminal "---------------------------------------------------------------------- noremap :call asclib#quickfix#scroll(2) noremap :call asclib#quickfix#scroll(3) noremap :call asclib#quickfix#scroll(4) noremap :call asclib#quickfix#scroll(5) noremap :call asclib#window#scroll('#', 6) noremap :call asclib#window#scroll('#', 7) noremap :call quickui#preview#scroll(-1) noremap :call quickui#preview#scroll(1) inoremap :call asclib#quickfix#scroll(2) inoremap :call asclib#quickfix#scroll(3) inoremap :call asclib#quickfix#scroll(4) inoremap :call asclib#quickfix#scroll(5) inoremap :call asclib#window#scroll('#', 6) inoremap :call asclib#window#scroll('#', 7) "---------------------------------------------------------------------- " space + f + num: session management "---------------------------------------------------------------------- set ssop-=options " do not store global and local values in a session " set ssop-=folds " do not store folds for s:index in range(5) exec 'nnoremap f'.s:index.'s :mksession! ~/.vim/session.'.s:index.'' exec 'nnoremap f'.s:index.'l :so ~/.vim/session.'.s:index.'' endfor "---------------------------------------------------------------------- " leader + b/c : buffer "---------------------------------------------------------------------- nnoremap bc :BufferClose nnoremap cw :CdToFileDir nnoremap cr :CdToProjectRoot "---------------------------------------------------------------------- " space + h : fast open files "---------------------------------------------------------------------- nnoremap hp :FileSwitch ~/.vim/project.txt nnoremap hf gf nnoremap he :call Show_Explore() nnoremap hb :FileSwitch ~/.vim/bundle.vim nnoremap hq :FileSwitch ~/.vim/quicknote.txt nnoremap hm :FileSwitch +setl\ ft=markdown ~/.vim/quicknote.md nnoremap hg :FileSwitch ~/.vim/scratch.txt nnoremap hd :FileSwitch ~/.vim/notes.md nnoremap ho :FileSwitch ~/.vim/cloud/Documents/cloudnote.txt nnoremap hi :FileSwitch ~/.vim/tasks.ini nnoremap ha : nnoremap h; :call asclib#nextcloud_sync() if (!has('nvim')) && (has('win32') || has('win64')) nnoremap hr :FileSwitch ~/_vimrc elseif !has('nvim') nnoremap hr :FileSwitch ~/.vimrc else nnoremap hr :FileSwitch ~/.config/nvim/init.vim endif if has('nvim') == 0 nnoremap hl :FileSwitch ~/.vim/local.vim else nnoremap hl :FileSwitch ~/.config/nvim/local.vim endif let $RTP = expand(':p:h:h') nnoremap hk :FileSwitch $RTP/init/keymaps.vim nnoremap hs :FileSwitch $RTP/skywind.vim nnoremap hv :FileSwitch $RTP/bundle.vim nnoremap hc :FileSwitch $RTP/autoload/asclib.vim nnoremap hu :FileSwitch $RTP/autoload/auxlib.vim nnoremap ht :FileSwitch $RTP/tasks.ini if has('win32') || has('win16') || has('win95') || has('win64') let s:autohk = expand('~/AppData/Roaming/Microsoft/Windows/Start Menu') let s:autohk = s:autohk . '/Programs/Startup/quickkeys.ahk' exec 'nnoremap ha :FileSwitch '. fnameescape(s:autohk). ' ' endif let s:nvimrc = expand("~/.config/nvim/init.vim") if has('win32') || has('win16') || has('win95') || has('win64') let s:nvimrc = expand("~/AppData/Local/nvim/init.vim") endif exec 'nnoremap h. :FileSwitch '.fnameescape(s:nvimrc).'' nnoremap hn :FileSwitch $RTP/neovim.lua "---------------------------------------------------------------------- " visual mode "---------------------------------------------------------------------- vnoremap gp :!python " vmap gs y/" vmap gs y/=escape(@", '\\/.*$^~[]') vmap gr y:%s/=escape(@", '\\/.*$^~[]')//gc "---------------------------------------------------------------------- " linting "---------------------------------------------------------------------- nnoremap lp :call asclib#lint_pylint('') nnoremap lf :call asclib#lint_flake8('') nnoremap ls :call asclib#lint_splint('') nnoremap lc :call asclib#lint_cppcheck('') nnoremap lg :call asclib#open_gprof('', '') nnoremap lt :call asclib#html_prettify() " last command nnoremap ll : "---------------------------------------------------------------------- " quickmenu "---------------------------------------------------------------------- noremap :call quickmenu#toggle(1) inoremap :call quickmenu#toggle(1) noremap :call quickmenu#toggle(2) inoremap :call quickmenu#toggle(2) nnoremap g5 :PreviewTag nnoremap ww :call asclib#touch_file('wsgi') nnoremap m0 :call quickmenu#toggle(0) nnoremap m1 :call quickmenu#toggle(1) nnoremap m2 :call quickmenu#toggle(2) nnoremap m3 :call quickmenu#toggle(3) "---------------------------------------------------------------------- " others "---------------------------------------------------------------------- nnoremap at :MyCheatSheetAlign vnoremap at :MyCheatSheetAlign nnoremap ab :CppBraceExpand vnoremap ab :CppBraceExpand noremap :call quickui#tools#list_function() noremap :call quickui#tools#list_function() noremap :call quickui#tools#list_function() if has('gui_macvim') noremap :call quickui#tools#list_function() noremap :call quickui#tools#list_function() noremap :call quickui#tools#list_function() endif "---------------------------------------------------------------------- " neovim system clipboard "---------------------------------------------------------------------- if (has('win32') || has('win64')) && (has('nvim') || (!has('gui_running'))) nnoremap "*P vnoremap "-d"*P inoremap * vnoremap "*y cnoremap * endif "---------------------------------------------------------------------- " space + s : svn "---------------------------------------------------------------------- nnoremap sc :AsyncRun svn co -m "update from vim" nnoremap su :AsyncRun svn up nnoremap st :AsyncRun svn st "---------------------------------------------------------------------- " Transferring blocks of text between vim sessions " http://www.drchip.org/astronaut/vim/index.html#Maps "---------------------------------------------------------------------- nmap xr :r $HOME/.vim/xfer nmap xw :'a,.w! $HOME/.vim/xfer vmap xw :w! $HOME/.vim/xfer nmap xa :'a,.w>> $HOME/.vim/xfer vmap xa :w>> $HOME/.vim/xfer nmap xS :so $HOME/.vim/xfer nmap xy :'a,.y * vmap xy :y *