inoremap jj inoremap call show_register#show() if has('nvim') tnoremap h tnoremap j tnoremap k tnoremap l endif nnoremap m wa make " nnoremap d call run() " function! s:run() abort " let cmd_table = {} " " let cmd_table.vim = 'w | source %' " let cmd_table.cpp = 'wa | wincmd t | call My_quickrun_redirect()' " let cmd_table.lua = 'w | luafile %' " let cmd_table.gnuplot = 'w | !gnuplot %' " let cmd = get(cmd_table, &filetype, 'w | QuickRun') " execute cmd " endfunction nnoremap h nnoremap j nnoremap k nnoremap l " resize window using arrow key nnoremap (win_screenpos(win_getid())[0] < 3) ? \":wincmd -" : ":wincmd +" nnoremap (win_screenpos(win_getid())[0] < 3) ? \":wincmd +" : ":wincmd -" nnoremap (win_screenpos(win_getid())[1] < 3) ? \":wincmd >" : ":wincmd <" nnoremap (win_screenpos(win_getid())[1] < 3) ? \":wincmd <" : ":wincmd >" nnoremap (win_screenpos(win_getid())[0] < 3) ? \":5wincmd -" : ":5wincmd +" nnoremap (win_screenpos(win_getid())[0] < 3) ? \":5wincmd +" : ":5wincmd -" nnoremap (win_screenpos(win_getid())[1] < 3) ? \":10wincmd >" : ":10wincmd <" nnoremap (win_screenpos(win_getid())[1] < 3) ? \":10wincmd <" : ":10wincmd >" nnoremap ; : xnoremap ; : " move around tabpages nnoremap gT nnoremap gt nnoremap tabmove - nnoremap tabmove + nnoremap t tabe " stop highlighting for search nnoremap nohlsearch " improved G nnoremap G Gzz7 "change local directory nnoremap cd tcd %:h " viml formatting function! s:format_viml() let tmp = winsaveview() normal! ggVG= call winrestview(tmp) endfunction nnoremap f call format_viml() " improved gd nnoremap gd call godef#go_to_definition() " multiple search nnoremap / multi_search#hl_last_match() . "/" nnoremap * multi_search#hl_last_match() . "*" nmap l "\" . multi_search#delete_search_all() nmap call smooth_scroll#up() nmap call smooth_scroll#down() vmap call smooth_scroll#up() vmap call smooth_scroll#down() " for sandwich.vim nmap s xmap s " from nelstrom/vim-visual-star-search function! s:VSetSearch(cmdtype) let temp = @" norm! y let @/ = '\V' . substitute(escape(@", a:cmdtype.'\'), '\n', '\\n', 'g') let @" = temp endfunction xnoremap * call VSetSearch('/')/=@/ xnoremap # call VSetSearch('?')?=@/ nnoremap j gj nnoremap k gk xnoremap j gj xnoremap k gk " for repeating indentation xnoremap > >call improved_indent()gv xnoremap < <call improved_indent()gv function! s:improved_indent() augroup my_indent autocmd cursormoved * call s:exit_indent_mode() augroup END let s:moved = v:false endfunction function! s:exit_indent_mode() if s:moved execute "normal! \" autocmd! my_indent let s:moved = v:false else let s:moved = v:true endif endfunction " insert parent directory of current file cnoremap %% getcmdtype() == ':' ? expand('%:p:h').'/' : '%%' cnoremap cnoremap cnoremap cnoremap cnoremap * cnoremap cnoremap " commands command! DeinClean :call map(dein#check_clean(), "delete(v:val, 'rf')") | \ call dein#recache_runtimepath() command! -range=% Typing :call typing#start(, , 1) command! LineCount :call line_counter#count() command! -nargs=1 -complete=customlist,s:find_sessions \ SaveSession :call save_session() command! MyUpdateRemotePlugins :call s:update_rplugins() function! s:update_rplugins() abort call dein#source(['defx.nvim', 'denite.nvim']) UpdateRemotePlugins endfunction function! s:find_sessions(...) abort let candidates = [] for f in split(glob('~/.vim/sessions/*'), '\n') call add(candidates, fnamemodify(f, ':t:r')) endfor return candidates endfunction function! s:save_session(arg) abort wall let name = substitute(a:arg, ' ', '_', 'g') . '.vim' let path = expand('~/.vim/sessions/') . name if filereadable(path) let choice = confirm(printf('%s already exists. Overwrite?', path), \"&Overwrite\n&Cancel") if choice == 2 return endif endif execute 'mksession!' . path endfunction " from https://zenn.dev/monaqa/articles/2020-09-17-vim-zenn-command function! s:create_zenn_article(article_name) abort let date = strftime("%Y-%m-%d") let slug = date . "-" . a:article_name call system("npx zenn new:article --slug " . slug ) let article_path = "articles/" . slug . ".md" execute "edit " . article_path endfunction command! -nargs=1 ZennCreateArticle call create_zenn_article("")