Replace various vim mappings with the noremap kind

This commit is contained in:
Michael Campagnaro 2021-12-15 20:49:00 -05:00
parent 8a6b0197e6
commit e5580826b9

109
vimrc
View File

@ -332,14 +332,14 @@ if &term =~ '256color'
endif endif
" Disable arrow keys. " Disable arrow keys.
map <up> <nop> noremap <up> <nop>
map <down> <nop> noremap <down> <nop>
map <left> <nop> noremap <left> <nop>
map <right> <nop> noremap <right> <nop>
imap <up> <nop> inoremap <up> <nop>
imap <down> <nop> inoremap <down> <nop>
imap <left> <nop> inoremap <left> <nop>
imap <right> <nop> inoremap <right> <nop>
"--------------------------------------------------------------- "---------------------------------------------------------------
" Load vimrc.private " Load vimrc.private
@ -505,7 +505,7 @@ augroup campoCmds
" Only allow one instance of ctags to run in this directory at any given time. " Only allow one instance of ctags to run in this directory at any given time.
let l:lock_file = "ctags.lock" let l:lock_file = "ctags.lock"
if filereadable(l:lock_file) || filereadable("newtags") 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 return
endif endif
@ -606,26 +606,25 @@ augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Mapping ESC in insert mode and command mode to double i. " Mapping ESC in insert mode and command mode to double i.
imap jj <Esc> imap jj <Esc>
"cmap ii <Esc>
" Suspend vim process and return to the shell. Can return to vim with `fg`. " Suspend vim process and return to the shell. Can return to vim with `fg`.
nmap <leader>z <c-z> nnoremap <leader>z <c-z>
" Open the vimrc file for editing / reload vimrc file. " Open the vimrc file for editing / reload vimrc file.
nmap <silent> <leader>ev :vsp $MYVIMRC<cr> nnoremap <silent> <leader>ev :vsp $MYVIMRC<cr>
nmap <silent> <leader>pv :vsp ~/.vimrc.private<cr> nnoremap <silent> <leader>pv :vsp ~/.vimrc.private<cr>
nmap <silent> <leader>rv :source $MYVIMRC<cr> nnoremap <silent> <leader>rv :source $MYVIMRC<cr>
" Type %/ in the command bar to have it replaced with the current buffer's " 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 " 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. " the full %/ quickly otherwise it won't replace it.
:cmap %/ %:p:h/ cmap %/ %:p:h/
" Remap saving and quiting. " Remap saving and quiting.
nmap <leader>w :w!<cr> nnoremap <leader>w :w!<cr>
nmap <leader>q :q<cr> nnoremap <leader>q :q<cr>
nmap <leader>qq :q!<cr> nnoremap <leader>qq :q!<cr>
nmap <leader>x :x<cr> nnoremap <leader>x :x<cr>
:ca Wa wa! :ca Wa wa!
:ca WA wa! :ca WA wa!
:ca WQ wq :ca WQ wq
@ -640,11 +639,11 @@ command! Q q " Bind :Q to :q
command! Qall qall command! Qall qall
command! Qa qall command! Qa qall
" Disable Ex mode. " Disable Ex mode.
map Q <Nop> noremap Q <Nop>
" Open a terminal within vim. Use `exit` to close it. " Open a terminal within vim. Use `exit` to close it.
if exists(':terminal') if exists(':terminal')
map <leader>t :terminal<cr> noremap <leader>t :terminal<cr>
tnoremap <leader>e <C-\><C-n> tnoremap <leader>e <C-\><C-n>
tnoremap <A-h> <C-\><C-n><C-w>h tnoremap <A-h> <C-\><C-n><C-w>h
tnoremap <A-j> <C-\><C-n><C-w>j tnoremap <A-j> <C-\><C-n><C-w>j
@ -657,10 +656,10 @@ if exists(':terminal')
endif endif
" Jump to other buffers. " Jump to other buffers.
map <c-k> <c-w><Up> noremap <c-k> <c-w><Up>
map <c-j> <c-w><Down> noremap <c-j> <c-w><Down>
map <c-l> <c-w><Right> noremap <c-l> <c-w><Right>
map <c-h> <c-w><Left> noremap <c-h> <c-w><Left>
" Make it easier to jump around the command line. The default behaviour is " Make it easier to jump around the command line. The default behaviour is
" using the arrow keys with or without shift. " using the arrow keys with or without shift.
@ -669,40 +668,38 @@ map <c-h> <c-w><Left>
" Window splitting - couldn't figure out how to remap <c-w>v & <c-w>n to <c-m> " Window splitting - couldn't figure out how to remap <c-w>v & <c-w>n to <c-m>
" & <c-n> " & <c-n>
map <leader>m :vsplit<cr> noremap <leader>m :vsplit<cr>
map <leader>mm :split<cr> noremap <leader>mm :split<cr>
" Forward delete and replace a word. " Forward delete and replace a word.
map <leader>d ciw noremap <leader>d ciw
" Allow fast pasting by accessing the system clipboard register. " Allow fast pasting by accessing the system clipboard register.
map <leader>p "+p noremap <leader>p "+p
" Likely won't need to use this if pasting with <leader>p, but just in case " Likely won't need to use this if pasting with <leader>p, but just in case here ya go.
" here ya go. noremap <leader>pp :set paste! paste?<cr>
map <leader>pp :set paste! paste?<cr>
map <leader>o :set number! number?<cr> " Toggle line numbers.
noremap <leader>o :set number! number?<cr>
" Show spell checking. " Show spell checking.
" @note: you can add new entries to the dict by moving the cursor over the " You can add new entries to the dict by moving the cursor over the word and pressing `zg`.
" word and pressing `zg`. noremap <leader>j :exec &spell==&spell? "se spell! spelllang=en_us" : "se spell!"<cr>
map <leader>j :exec &spell==&spell? "se spell! spelllang=en_us" : "se spell!"<cr> noremap <leader>= z=
map <leader>= z=
" Clear the search buffer (highlighting) when hitting return. " Clear the search buffer (highlighting) when hitting return.
function! MapCR() nnoremap <cr> :nohlsearch<cr>
nnoremap <cr> :nohlsearch<cr>
endfunction " Switch to the previous file.
call MapCR()
nnoremap <leader><leader> <c-^> nnoremap <leader><leader> <c-^>
" Replace currently selected text with default register without yanking it. " Replace currently selected text with default register without yanking it.
vnoremap p "_dP vnoremap p "_dP
" Switch between C++ source and header files. " Switch between C++ source and header files.
map <leader>v :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR> noremap <leader>v :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>
"map <leader>vv :e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c,<CR> "noremap <leader>vv :e %:p:s,.h$,.X123X,:s,.c$,.h,:s,.X123X$,.c,<CR>
"map <leader>vvv :e %:p:s,.h$,.X123X,:s,.cc$,.h,:s,.X123X$,.cc,<CR> "noremap <leader>vvv :e %:p:s,.h$,.X123X,:s,.cc$,.h,:s,.X123X$,.cc,<CR>
" Replace all instances of the highlighted text with whatever you enter. " Replace all instances of the highlighted text with whatever you enter.
nnoremap <c-g> :%s///g<left><left> nnoremap <c-g> :%s///g<left><left>
@ -772,9 +769,9 @@ noremap <F12> :TagbarToggle<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:gitgutter_enabled = 1 let g:gitgutter_enabled = 1
let g:gitgutter_highlight_lines = 0 let g:gitgutter_highlight_lines = 0
nmap <leader>ha <Plug>GitGutterStageHunk nnoremap <leader>hh :GitGutterToggle<cr>
nmap <leader>hh :GitGutterToggle<cr> nmap <leader>ha <Plug>(GitGutterStageHunk)
nmap [h <Plug>GitGutterNextHunk nmap [h <Plug>(GitGutterNextHunk)
nmap ]h <Plug>GitGutterPrevHunk nmap ]h <Plug>GitGutterPrevHunk
augroup gitGutterPluginCmds 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-o = ask how to open a file search result.
" ctrl-p | ctrl-n = traverse search history. " ctrl-p | ctrl-n = traverse search history.
map <leader>g :CtrlP<cr> noremap <leader>g :CtrlP<cr>
let g:ctrlp_map = '<leader>f' let g:ctrlp_map = '<leader>f'
let g:ctrlp_cmd = 'CtrlPTag' " Search tags by default. let g:ctrlp_cmd = 'CtrlPTag' " Search tags by default.
let g:ctrlp_by_filename = 1 " File search by filename as opposed to full path. 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 " GIT
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <leader>gb :Git blame -w<cr> noremap <leader>gb :Git blame -w<cr>
" Ignore whitespace changes; follow renames and copies. " Ignore whitespace changes; follow renames and copies.
command! -bar -bang -nargs=* Blame :Git blame<bang> -wCM <args> command! -bar -bang -nargs=* Blame :Git blame<bang> -wCM <args>
command! -bar -bang -nargs=* Gblame :Git blame<bang> -wCM <args> command! -bar -bang -nargs=* Gblame :Git blame<bang> -wCM <args>
@ -968,8 +965,8 @@ exec "autocmd ColorScheme " . g:campo_dark_theme . " call ReloadRainbow()"
exec "autocmd ColorScheme " . g:campo_light_theme . " call ReloadRainbow()" exec "autocmd ColorScheme " . g:campo_light_theme . " call ReloadRainbow()"
" Switch between light and dark themes. " Switch between light and dark themes.
map <leader>l :call ChangeBgTheme('light', 0)<cr> noremap <leader>l :call ChangeBgTheme('light', 0)<cr>
map <leader>ll :call ChangeBgTheme('dark', 0)<cr> noremap <leader>ll :call ChangeBgTheme('dark', 0)<cr>
function! ChangeBgTheme(bg, onlySetTheme) function! ChangeBgTheme(bg, onlySetTheme)
if a:bg =~ 'light' if a:bg =~ 'light'
@ -1160,11 +1157,11 @@ function! Search(case_sensitive, search_args)
endfunction endfunction
" Case insensitive " Case insensitive
map <leader>s :call Search(0, g:campo_custom_search_args)<cr> noremap <leader>s :call Search(0, g:campo_custom_search_args)<cr>
noremap <F2> :call Search(0, g:campo_custom_search_args_2)<cr> noremap <F2> :call Search(0, g:campo_custom_search_args_2)<cr>
" Case sensitive " Case sensitive
map <leader>ss :call Search(1, g:campo_custom_search_args)<cr> noremap <leader>ss :call Search(1, g:campo_custom_search_args)<cr>
noremap <F3> :call Search(1, g:campo_custom_search_args_2)<cr> noremap <F3> :call Search(1, g:campo_custom_search_args_2)<cr>
" Navigation for the vim-ripgrep search results. " 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!") call PrintError("Unable to search since you're not in a git repo!")
endif endif
endfunction endfunction
map <leader>r :call GlobalReplaceIt(0)<cr> noremap <leader>r :call GlobalReplaceIt(0)<cr>
map <leader>rr :call GlobalReplaceIt(1)<cr> noremap <leader>rr :call GlobalReplaceIt(1)<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@ -1249,7 +1246,7 @@ function! RenameFile()
redraw! redraw!
endif endif
endfunction endfunction
map <leader>n :call RenameFile()<cr> noremap <leader>n :call RenameFile()<cr>
"--------------------------------------------------------------------------------------------------- "---------------------------------------------------------------------------------------------------