From e5580826b920062ca1dcae36eeee54c95886c20d Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Wed, 15 Dec 2021 20:49:00 -0500 Subject: [PATCH] Replace various vim mappings with the noremap kind --- vimrc | 109 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 53 insertions(+), 56 deletions(-) diff --git a/vimrc b/vimrc index c9b1a79..447ec5b 100644 --- a/vimrc +++ b/vimrc @@ -332,14 +332,14 @@ if &term =~ '256color' endif " Disable arrow keys. -map -map -map -map -imap -imap -imap -imap +noremap +noremap +noremap +noremap +inoremap +inoremap +inoremap +inoremap "--------------------------------------------------------------- " Load vimrc.private @@ -505,7 +505,7 @@ augroup campoCmds " Only allow one instance of ctags to run in this directory at any given time. let l:lock_file = "ctags.lock" if filereadable(l:lock_file) || filereadable("newtags") - call PrintError("ctags already running (found ".l:lock_file." or newtags file)") + " Don't print a warning because this will always show when saving multiple files at the same time with a :wa or :xa return endif @@ -606,26 +606,25 @@ augroup END """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Mapping ESC in insert mode and command mode to double i. imap jj -"cmap ii " Suspend vim process and return to the shell. Can return to vim with `fg`. -nmap z +nnoremap z " Open the vimrc file for editing / reload vimrc file. -nmap ev :vsp $MYVIMRC -nmap pv :vsp ~/.vimrc.private -nmap rv :source $MYVIMRC +nnoremap ev :vsp $MYVIMRC +nnoremap pv :vsp ~/.vimrc.private +nnoremap rv :source $MYVIMRC " Type %/ in the command bar to have it replaced with the current buffer's " path if the file is on disk. One thing I noticed is that you have to type " the full %/ quickly otherwise it won't replace it. -:cmap %/ %:p:h/ +cmap %/ %:p:h/ " Remap saving and quiting. -nmap w :w! -nmap q :q -nmap qq :q! -nmap x :x +nnoremap w :w! +nnoremap q :q +nnoremap qq :q! +nnoremap x :x :ca Wa wa! :ca WA wa! :ca WQ wq @@ -640,11 +639,11 @@ command! Q q " Bind :Q to :q command! Qall qall command! Qa qall " Disable Ex mode. -map Q +noremap Q " Open a terminal within vim. Use `exit` to close it. if exists(':terminal') - map t :terminal + noremap t :terminal tnoremap e tnoremap h tnoremap j @@ -657,10 +656,10 @@ if exists(':terminal') endif " Jump to other buffers. -map -map -map -map +noremap +noremap +noremap +noremap " Make it easier to jump around the command line. The default behaviour is " using the arrow keys with or without shift. @@ -669,40 +668,38 @@ map " Window splitting - couldn't figure out how to remap v & n to " & -map m :vsplit -map mm :split +noremap m :vsplit +noremap mm :split " Forward delete and replace a word. -map d ciw +noremap d ciw " Allow fast pasting by accessing the system clipboard register. -map p "+p -" Likely won't need to use this if pasting with p, but just in case -" here ya go. -map pp :set paste! paste? +noremap p "+p +" Likely won't need to use this if pasting with p, but just in case here ya go. +noremap pp :set paste! paste? -map o :set number! number? +" Toggle line numbers. +noremap o :set number! number? " Show spell checking. -" @note: you can add new entries to the dict by moving the cursor over the -" word and pressing `zg`. -map j :exec &spell==&spell? "se spell! spelllang=en_us" : "se spell!" -map = z= +" You can add new entries to the dict by moving the cursor over the word and pressing `zg`. +noremap j :exec &spell==&spell? "se spell! spelllang=en_us" : "se spell!" +noremap = z= " Clear the search buffer (highlighting) when hitting return. -function! MapCR() - nnoremap :nohlsearch -endfunction -call MapCR() +nnoremap :nohlsearch + +" Switch to the previous file. nnoremap " Replace currently selected text with default register without yanking it. vnoremap p "_dP " Switch between C++ source and header files. -map v :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp, -"map vv :e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c, -"map vvv :e %:p:s,.h$,.X123X,:s,.cc$,.h,:s,.X123X$,.cc, +noremap v :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp, +"noremap vv :e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c, +"noremap vvv :e %:p:s,.h$,.X123X,:s,.cc$,.h,:s,.X123X$,.cc, " Replace all instances of the highlighted text with whatever you enter. nnoremap :%s///g @@ -772,9 +769,9 @@ noremap :TagbarToggle """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let g:gitgutter_enabled = 1 let g:gitgutter_highlight_lines = 0 -nmap ha GitGutterStageHunk -nmap hh :GitGutterToggle -nmap [h GitGutterNextHunk +nnoremap hh :GitGutterToggle +nmap ha (GitGutterStageHunk) +nmap [h (GitGutterNextHunk) nmap ]h GitGutterPrevHunk augroup gitGutterPluginCmds @@ -824,7 +821,7 @@ let g:rg_window_height = g:quickfix_pane_height " ctrl-o = ask how to open a file search result. " ctrl-p | ctrl-n = traverse search history. -map g :CtrlP +noremap g :CtrlP let g:ctrlp_map = 'f' let g:ctrlp_cmd = 'CtrlPTag' " Search tags by default. let g:ctrlp_by_filename = 1 " File search by filename as opposed to full path. @@ -846,7 +843,7 @@ let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standar " GIT """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -map gb :Git blame -w +noremap gb :Git blame -w " Ignore whitespace changes; follow renames and copies. command! -bar -bang -nargs=* Blame :Git blame -wCM command! -bar -bang -nargs=* Gblame :Git blame -wCM @@ -968,8 +965,8 @@ exec "autocmd ColorScheme " . g:campo_dark_theme . " call ReloadRainbow()" exec "autocmd ColorScheme " . g:campo_light_theme . " call ReloadRainbow()" " Switch between light and dark themes. -map l :call ChangeBgTheme('light', 0) -map ll :call ChangeBgTheme('dark', 0) +noremap l :call ChangeBgTheme('light', 0) +noremap ll :call ChangeBgTheme('dark', 0) function! ChangeBgTheme(bg, onlySetTheme) if a:bg =~ 'light' @@ -1160,11 +1157,11 @@ function! Search(case_sensitive, search_args) endfunction " Case insensitive -map s :call Search(0, g:campo_custom_search_args) +noremap s :call Search(0, g:campo_custom_search_args) noremap :call Search(0, g:campo_custom_search_args_2) " Case sensitive -map ss :call Search(1, g:campo_custom_search_args) +noremap ss :call Search(1, g:campo_custom_search_args) noremap :call Search(1, g:campo_custom_search_args_2) " Navigation for the vim-ripgrep search results. @@ -1233,8 +1230,8 @@ function! GlobalReplaceIt(confirm_replacement) range call PrintError("Unable to search since you're not in a git repo!") endif endfunction -map r :call GlobalReplaceIt(0) -map rr :call GlobalReplaceIt(1) +noremap r :call GlobalReplaceIt(0) +noremap rr :call GlobalReplaceIt(1) """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -1249,7 +1246,7 @@ function! RenameFile() redraw! endif endfunction -map n :call RenameFile() +noremap n :call RenameFile() "---------------------------------------------------------------------------------------------------