From d06770efeff8b9e35d74895fa978fa7de1348eb3 Mon Sep 17 00:00:00 2001 From: jdhao Date: Mon, 19 Oct 2020 22:59:27 +0800 Subject: [PATCH] add in mappings that use command where appropriate --- after/ftplugin/cpp.vim | 2 +- after/ftplugin/python.vim | 2 +- mappings.vim | 46 +++++++++++++++++++-------------------- plugins.vim | 16 +++++++------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/after/ftplugin/cpp.vim b/after/ftplugin/cpp.vim index 7962700..4fe80ab 100644 --- a/after/ftplugin/cpp.vim +++ b/after/ftplugin/cpp.vim @@ -1 +1 @@ -nnoremap :w :!g++ -Wall -std=c++11 % -o %<&&./%< +nnoremap :w :!g++ -Wall -std=c++11 % -o %<&&./%< diff --git a/after/ftplugin/python.vim b/after/ftplugin/python.vim index 0caca7d..f8177db 100644 --- a/after/ftplugin/python.vim +++ b/after/ftplugin/python.vim @@ -1,5 +1,5 @@ if exists(':AsyncRun') - nnoremap :AsyncRun python -u "%" + nnoremap :AsyncRun python -u "%" endif " Do not wrap Python source code. diff --git a/mappings.vim b/mappings.vim index fda96b9..b777216 100644 --- a/mappings.vim +++ b/mappings.vim @@ -23,29 +23,29 @@ nnoremap p m`op`` nnoremap P m`Op`` " Shortcut for faster save and quit -nnoremap w :update +nnoremap w :update " Saves the file if modified and quit -nnoremap q :x +nnoremap q :x " Quit all opened buffers -nnoremap Q :qa +nnoremap Q :qa " Navigation in the location and quickfix list -nnoremap [l :lpreviouszv -nnoremap ]l :lnextzv -nnoremap [L :lfirstzv -nnoremap ]L :llastzv -nnoremap [q :cpreviouszv -nnoremap ]q :cnextzv -nnoremap [Q :cfirstzv -nnoremap ]Q :clastzv +nnoremap [l :lpreviouszv +nnoremap ]l :lnextzv +nnoremap [L :lfirstzv +nnoremap ]L :llastzv +nnoremap [q :cpreviouszv +nnoremap ]q :cnextzv +nnoremap [Q :cfirstzv +nnoremap ]Q :clastzv " Close location list or quickfix list if they are present, " see https://superuser.com/q/355325/736190 -nnoremap \x :windo lclose cclose +nnoremap \x :windo lclose cclose " Close a buffer and switching to another buffer, do not close the " window, see https://stackoverflow.com/q/4465095/6064933 -nnoremap \d :bprevious bdelete # +nnoremap \d :bprevious bdelete # " Insert a blank line below or above current line (do not move the cursor), " see https://stackoverflow.com/a/16136133/6064933 @@ -115,8 +115,8 @@ inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" " Edit and reload init.vim quickly -nnoremap ev :tabnew $MYVIMRC tcd %:h -nnoremap sv :silent update $MYVIMRC source $MYVIMRC +nnoremap ev :tabnew $MYVIMRC tcd %:h +nnoremap sv :silent update $MYVIMRC source $MYVIMRC \ echomsg "Nvim config successfully reloaded!" " Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933. @@ -131,15 +131,15 @@ xnoremap :s/ " Change current working directory locally and print cwd after that, " see https://vim.fandom.com/wiki/Set_working_directory_to_the_current_file -nnoremap cd :lcd %:p:h:pwd +nnoremap cd :lcd %:p:h:pwd " Use Esc to quit builtin terminal tnoremap " Toggle spell checking (autosave does not play well with z=, so we disable it " when we are doing spell checking) -nnoremap :set spell! :AutoSaveToggle -inoremap :set spell! :AutoSaveToggle +nnoremap :set spell! :AutoSaveToggle +inoremap :set spell! :AutoSaveToggle " Decrease indent level in insert mode with shift+tab inoremap < :call utils#StripTrailingWhitespaces() +nnoremap :call utils#StripTrailingWhitespaces() " check the syntax group of current cursor position -nnoremap st :call utils#SynGroup() +nnoremap st :call utils#SynGroup() " Clear highlighting if maparg('', 'n') ==# '' - nnoremap :nohlsearch=has('diff')?'diffupdate':'' + nnoremap :nohlsearch=has('diff')?'diffupdate':'' endif " Copy entire buffer. -nnoremap y :%y +nnoremap y :%y " Toggle cursor column -nnoremap cl :call utils#ToggleCursorCol() +nnoremap cl :call utils#ToggleCursorCol() " Move current line up and down nnoremap call utils#SwitchLine(line('.'), 'up') diff --git a/plugins.vim b/plugins.vim index 20c52a3..eb95718 100644 --- a/plugins.vim +++ b/plugins.vim @@ -469,11 +469,11 @@ let g:Lf_ShortcutF = '' let g:Lf_ShortcutB = '' " Search files in popup window -nnoremap f :Leaderf file --popup +nnoremap f :Leaderf file --popup " Search vim help files -nnoremap h :Leaderf help --popup +nnoremap h :Leaderf help --popup " Search tags in current buffer -nnoremap t :Leaderf bufTag --popup +nnoremap t :Leaderf bufTag --popup "}} "{{ URL related @@ -491,7 +491,7 @@ endif "{{ Navigation and tags """"""""""""""""""""""""""" tagbar settings """""""""""""""""""""""""""""""""" " Shortcut to toggle tagbar window -" nnoremap t :TagbarToggle +" nnoremap t :TagbarToggle " Add support for markdown files in tagbar. if g:is_win @@ -528,7 +528,7 @@ let g:vista_echo_cursor = 0 " Stay in current window when vista window is opened let g:vista_stay_on_open = 0 -nnoremap t :Vista!! +nnoremap t :Vista!! function! s:close_vista_win() abort if winnr('$') == 1 && getbufvar(bufnr(), '&filetype') ==# 'vista' @@ -659,8 +659,8 @@ if g:is_win || g:is_mac let g:mkdp_auto_close = 0 " Shortcuts to start and stop markdown previewing - nnoremap :MarkdownPreview - nnoremap :MarkdownPreviewStop + nnoremap :MarkdownPreview + nnoremap :MarkdownPreviewStop endif """"""""""""""""""""""""vim-markdownfootnotes settings"""""""""""""""""""""""" @@ -876,6 +876,6 @@ if exists('g:started_by_firenvim') && g:started_by_firenvim endif """"""""""""""""""""""""""""""nvim-gdb settings"""""""""""""""""""""""""""""" -nnoremap dp :GdbStartPDB python -m pdb % +nnoremap dp :GdbStartPDB python -m pdb % "}} "}