From 39fdace95938b24f66ee9bc7c7efb0a585ed98ce Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 20 Nov 2018 09:51:58 +0800 Subject: vim: Use non-recursive map commands --- _vim/vimrc | 82 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/_vim/vimrc b/_vim/vimrc index 941ccb6..ccbaab8 100644 --- a/_vim/vimrc +++ b/_vim/vimrc @@ -22,7 +22,7 @@ set autoread let mapleader = "," " Fast saving -nmap w :w! +nnoremap w :w! " :W sudo saves the file " (useful for handling the permission-denied error) @@ -152,52 +152,52 @@ set formatoptions+=m " Break at multi-byte characters (e.g., CJK) """""""""""""""""""""""""""""" " Visual mode pressing * or # searches for the current selection " Super useful! From an idea by Michael Naumann -vnoremap * :call VisualSelection('', '')/=@/ -vnoremap # :call VisualSelection('', '')?=@/ +vnoremap * :call VisualSelection('', '')/=@/ +vnoremap # :call VisualSelection('', '')?=@/ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Moving around, tabs, windows and buffers """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -map / -map ? +noremap / +noremap ? " Disable highlight when is pressed -map :noh +noremap :nohlsearch " Smart way to move between windows -map j -map k -map h -map l +noremap j +noremap k +noremap h +noremap l " Close the current buffer -map bd :Bclose:tabclosegT +noremap bd :Bclose:tabclosegT " Close all the buffers -map ba :bufdo bd +noremap ba :bufdo bd -map l :bnext -map h :bprevious +noremap l :bnext +noremap h :bprevious " Useful mappings for managing tabs -map tn :tabnew -map to :tabonly -map tc :tabclose -map tm :tabmove -map t :tabnext +noremap tn :tabnew +noremap to :tabonly +noremap tc :tabclose +noremap tm :tabmove +noremap t :tabnext " Let 'tl' toggle between this and the last accessed tab let g:lasttab = 1 -nmap tl :exe "tabn ".g:lasttab +nnoremap tl :exe "tabn ".g:lasttab autocmd TabLeave * let g:lasttab = tabpagenr() " Opens a new tab with the current buffer's path " Super useful when editing files in the same directory -map te :tabedit =expand("%:p:h")/ +noremap te :tabedit =expand("%:p:h")/ " Switch CWD to the directory of the open buffer -map cd :cd %:p:h:pwd +noremap cd :cd %:p:h:pwd " Specify the behavior when switching between buffers set switchbuf=useopen,usetab,newtab @@ -231,16 +231,16 @@ set statusline+=\ " blank space " => Editing mappings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Move a line of text using ALT+[jk] or Command+[jk] on mac -nmap mz:m+`z -nmap mz:m-2`z -vmap :m'>+`mzgv`yo`z -vmap :m'<-2`>my` mz:m+`z +nnoremap mz:m-2`z +vnoremap :m'>+`mzgv`yo`z +vnoremap :m'<-2`>my` - nmap - vmap - vmap + nnoremap + nnoremap + vnoremap + vnoremap endif " Delete trailing white space on save, useful for some filetypes ;) @@ -261,33 +261,33 @@ autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces( set spelllang=en_us,cjk " Pressing ,ss will toggle and untoggle spell checking -map ss :setlocal spell! +noremap ss :setlocal spell! " Shortcuts using -map sn ]s -map sp [s -map sa zg -map s? z= +noremap sn ]s +noremap sp [s +noremap sa zg +noremap s? z= """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Misc """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Remove the Windows ^M - when the encodings gets messed up -noremap m mmHmt:%s///ge'tzt'm +noremap m mmHmt:%s///ge'tzt'm " Quickly open a buffer for scribble -map q :e ~/buffer +noremap q :e ~/buffer " Quickly open a markdown buffer for scribble -map x :e ~/buffer.md +noremap x :e ~/buffer.md " Toggle paste mode on and off -map pp :setlocal paste! +noremap pp :setlocal paste! " Disable F1 to open the help -map -imap +noremap +inoremap """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -- cgit v1.2.2