nnoremap let g:mapleader = ' ' inoremap nnoremap :tabprevious nnoremap :tabnext noremap gT noremap gt " nnoremap tk T " Quickly insert an empty new line without entering insert mode nnoremap o o nnoremap O O " nnoremap " nnoremap " inoremap " inoremap " workman noremap noremap noremap e j noremap o k noremap n h noremap i l vnoremap i l noremap k n noremap h e noremap l o noremap f u noremap u i noremap E J noremap O K noremap N H noremap I L noremap K N noremap H E noremap L O noremap F U noremap U I noremap ge gj noremap go gk noremap gn gh noremap gl go noremap gk gn noremap gh ge noremap gE gJ noremap gN gH noremap gK gN noremap gH gE noremap gL gO nnoremap e :wincmd j nnoremap o :wincmd k nnoremap n :wincmd h nnoremap i :wincmd l nnoremap k :wincmd n nnoremap l :wincmd o vnoremap B vnoremap W nnoremap B nnoremap W vnoremap b vnoremap w nnoremap b nnoremap w " nnoremap i e " get control-j back, so switch it with ctrl-n at qwerty position of j " imap " cmap inoremap cnoremap " jump word in visual mode -- TODO " In insert or command mode, move normally by using Ctrl inoremap inoremap inoremap inoremap cnoremap cnoremap cnoremap cnoremap inoremap inoremap inoremap :+3i inoremap :-3i " easy config nmap :e $HOME/.vimrc nmap :so $HOME/.vimrc " Force saving files that require root permission command! SUDOwrite :execute 'w !sudo tee > /dev/null %' | edit! " TODO: C-S-o etc does not work " Bubble single lines nmap :m-2== nmap :m-2== nmap :m+== nmap :m+== imap :m-2==gi imap :m-2==gi imap :m+==gi imap :m+==gi " Bubble multiple lines vmap :m-2gv=gv vmap :m-2gv=gv vmap :m'>+gv=gv vmap :m'>+gv=gv " Indent lines using and vmap >gv nmap >> imap >>i vmap << imap < :lprevious " noremap :lnext " moving through buffers " noremap :bn " noremap :bp noremap bd :bd noremap wc :bd noremap bo :Bufonly " close preview nmap pc :pc " Remap window commands " map ws :wincmd s " map wv :wincmd v " map wc :wincmd c " map wn :wincmd n " map wo :wincmd o " map w+ :wincmd _ " map w- :wincmd " map w= :wincmd = " nmap + :vertical resize +20 " nmap - :vertical resize -20 " map :wincmd > " map :wincmd j " map :wincmd j " map :wincmd k " map :wincmd k " map :wincmd h " map :wincmd h " map :wincmd l " map :wincmd l " " nnoremap :wincmd k " nnoremap :wincmd j " nnoremap :wincmd h " nnoremap :wincmd l " inoremap :wincmd k " inoremap :wincmd j " inoremap :wincmd h " inoremap :wincmd l nnoremap :wincmd k nnoremap :wincmd j nnoremap :wincmd h nnoremap :wincmd l nnoremap :wincmd k nnoremap :wincmd j nnoremap :wincmd h nnoremap :wincmd l inoremap :wincmd k inoremap :wincmd j inoremap :wincmd h inoremap :wincmd l nnoremap :wincmd K nnoremap :wincmd J nnoremap :wincmd H nnoremap :wincmd L inoremap :wincmd K inoremap :wincmd J inoremap :wincmd H inoremap :wincmd L " tags nmap :exec("tjump ".expand("")) nmap :split:exec("tjump ".expand("")) " trigger NERDTree, Tagbar $ Co. " nmap n :NERDTreeToggle " nmap t :TagbarToggle " nmap f "zyaw :exe ":Ack ".@z."" " grep word under cursor nnoremap f :lgr! "\b\b":cw " paste from system clipboard inoremap :set paste"+p :set nopaste " toggle spellcheck nmap :setlocal spell! spelllang=en_us " cursor jump " nnoremap 3k " inoremap :-3i " vnoremap 3k " nnoremap 3j " inoremap :+3i " vnoremap 3j " nnoremap 6k " inoremap :-6i " vnoremap 6k " nnoremap 6j " inoremap :+6i " vnoremap 6j nnoremap 3k vnoremap 3k nnoremap 3j vnoremap 3j nnoremap 6k vnoremap 6k nnoremap 6j vnoremap 6j " scrolling nnoremap 10 " inoremap 10i vnoremap 10 nnoremap 10 " inoremap 10i vnoremap 10 nnoremap 10 " inoremap 10i vnoremap 10 nnoremap 10 " inoremap 10i vnoremap 10 nnoremap " inoremap i vnoremap nnoremap " inoremap i vnoremap " half scroll up and down noremap noremap map " F keys " nmap :noh " imap :noh noremap :FufBuffer nmap :call ManCurrentWord() " nmap :call DevHelpCurrentWord() " nmap " remap visual block nnoremap " write noremap :w inoremap :w " exit noremap :qa! inoremap :qa! " paste nnoremap "+gPl vnoremap :call Paste("v") inoremap :call Paste("i") " select all nnoremap ggVG inoremap :call Select() nnoremap cd :cd %:p:h:pwd nnoremap cc :cclose nnoremap co :copen function! ToggleQuickFix() if empty(filter(getwininfo(), 'v:val.quickfix')) copen else cclose endif endfunction function! ToggleLocList() if empty(filter(getwininfo(), 'v:val.loclist')) lopen else lclose endif endfunction nnoremap :call ToggleQuickFix() nnoremap :call ToggleLocList() " PLUGINS " NERDTree if !exists('g:vscode') noremap :NERDTreeToggle " noremap :TagbarToggle inoremap :TagbarToggle endif " vista nmap :Vista!! " NERDComment if !exists('g:vscode') nnoremap :call NERDComment("n", "Toggle") vnoremap :call NERDComment("v", "Toggle") endif " YCM if !exists('g:vscode') nmap :YcmCompleter GoTo:wincmd o endif " vim-clap if !exists('g:vscode') if has('nvim') nnoremap ag lua require('telescope.builtin').live_grep({ default_text = vim.fn.expand("") }) nnoremap tg lua require('telescope.builtin').tags({ default_text = vim.fn.expand("") }) nmap :call ComIfGit('lua require("telescope.builtin").git_files()', 'lua require("telescope.builtin").find_files()') nmap lua require('telescope.builtin').tags() nmap lua require('telescope.builtin').buffers() nmap lua require('telescope.builtin').diagnostics() nmap lua require('telescope.builtin').lsp_document_symbols() nnoremap ls lua require('telescope.builtin').lsp_document_symbols({ default_text = vim.fn.expand("") }) else nnoremap ag :Clap grep ++query= nnoremap dg :Clap dumb_jump ++query= " nnoremap tg :Clap proj_tags ++query= nmap :call ComIfGit('Clap gfiles', 'Clap files') nmap :Clap tags nmap :Clap proj_tags nmap :Clap buffers nnoremap tb :Clap proj_tags ++query= endif endif " tags nnoremap tg :tag =expand("") nnoremap tp :ptag =expand("") nnoremap ts :ts =expand("") " gitgutter if !exists('g:vscode') nmap ggt :GitGutterToggle nmap nh (GitGutterNextHunk) nmap bh (GitGutterPrevHunk) " tig " let g:tig_explorer_keymap_edit = '' " let g:tig_explorer_keymap_tabedit = '' " let g:tig_explorer_keymap_split = '' " let g:tig_explorer_keymap_vsplit = '' " nnoremap T :TigOpenCurrentFile " nnoremap t :TigOpenProjectRootDir " nnoremap g :TigGrep " nnoremap r :TigGrepResume " vnoremap g y:TigGrep" " nnoremap cg ::TigGrep " nnoremap b :TigBlame " ghcup " nnoremap ghc :GHCup " git gutter omap ic (GitGutterTextObjectInnerPending) omap ac (GitGutterTextObjectOuterPending) xmap ic (GitGutterTextObjectInnerVisual) xmap ac (GitGutterTextObjectOuterVisual) endif " fastfold nmap zuz (FastFoldUpdate) if exists('g:vscode') nnoremap T :call VSCodeNotify('editor.action.showHover') nnoremap gd :call VSCodeNotify('editor.action.revealDefinition') else if has('nvim') nnoremap T :lua vim.lsp.buf.hover() nnoremap gd :lua vim.lsp.buf.definition() nnoremap la :lua vim.lsp.buf.code_action() nnoremap rn :lua vim.lsp.buf.rename() nnoremap ln (lcn-diagnostics-next) nnoremap lp (lcn-diagnostics-prev) " Vim Script nnoremap xx TroubleToggle nnoremap xw TroubleToggle workspace_diagnostics nnoremap xd TroubleToggle document_diagnostics nnoremap xq TroubleToggle quickfix nnoremap xl TroubleToggle loclist nnoremap gR TroubleToggle lsp_references else "LanguageClient-neovim " Required for operations modifying multiple buffers like rename. set hidden nnoremap lc :call LanguageClient_contextMenu() " Or map each action separately nnoremap T :call LanguageClient#textDocument_hover() nnoremap gd :call LanguageClient#textDocument_definition() " nnoremap :call LanguageClient#textDocument_rename() " nnoremap ld :call LanguageClient#textDocument_definition() " nnoremap lr :call LanguageClient#textDocument_rename() " nnoremap lf :call LanguageClient#textDocument_formatting() " nnoremap lt :call LanguageClient#textDocument_typeDefinition() " nnoremap lx :call LanguageClient#textDocument_references() " nnoremap la :call LanguageClient_workspace_applyEdit() " nnoremap lc :call LanguageClient#textDocument_completion() " nnoremap lh :call LanguageClient#textDocument_hover() nnoremap la :call LanguageClient#textDocument_codeAction() nnoremap rn :call LanguageClient#textDocument_rename() nnoremap ln (lcn-diagnostics-next) nnoremap lp (lcn-diagnostics-prev) endif endif