diff options
author | Aaron LI <aly@aaronly.me> | 2018-11-20 09:51:58 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-11-20 09:51:58 +0800 |
commit | 39fdace95938b24f66ee9bc7c7efb0a585ed98ce (patch) | |
tree | 148fa9f20e3231bed832cfdb9ff6364b0d21a1bf | |
parent | 2a4a17074e22fe4ce6959d358f23d432191a0493 (diff) | |
download | dotfiles-39fdace95938b24f66ee9bc7c7efb0a585ed98ce.tar.bz2 |
vim: Use non-recursive map commands
-rw-r--r-- | _vim/vimrc | 82 |
1 files changed, 41 insertions, 41 deletions
@@ -22,7 +22,7 @@ set autoread let mapleader = "," " Fast saving -nmap <leader>w :w!<cr> +nnoremap <leader>w :w!<cr> " :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 <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR> -vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR> +vnoremap <silent> * :<C-u>call VisualSelection('', '')<cr>/<C-r>=@/<cr><cr> +vnoremap <silent> # :<C-u>call VisualSelection('', '')<cr>?<C-r>=@/<cr><cr> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Moving around, tabs, windows and buffers """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -map <space> / -map <c-space> ? +noremap <space> / +noremap <C-space> ? " Disable highlight when <leader><cr> is pressed -map <silent> <leader><cr> :noh<cr> +noremap <silent> <leader><cr> :nohlsearch<cr> " Smart way to move between windows -map <C-j> <C-W>j -map <C-k> <C-W>k -map <C-h> <C-W>h -map <C-l> <C-W>l +noremap <C-j> <C-w>j +noremap <C-k> <C-w>k +noremap <C-h> <C-w>h +noremap <C-l> <C-w>l " Close the current buffer -map <leader>bd :Bclose<cr>:tabclose<cr>gT +noremap <leader>bd :Bclose<cr>:tabclose<cr>gT " Close all the buffers -map <leader>ba :bufdo bd<cr> +noremap <leader>ba :bufdo bd<cr> -map <leader>l :bnext<cr> -map <leader>h :bprevious<cr> +noremap <leader>l :bnext<cr> +noremap <leader>h :bprevious<cr> " Useful mappings for managing tabs -map <leader>tn :tabnew<cr> -map <leader>to :tabonly<cr> -map <leader>tc :tabclose<cr> -map <leader>tm :tabmove -map <leader>t<leader> :tabnext +noremap <leader>tn :tabnew<cr> +noremap <leader>to :tabonly<cr> +noremap <leader>tc :tabclose<cr> +noremap <leader>tm :tabmove +noremap <leader>t<leader> :tabnext " Let 'tl' toggle between this and the last accessed tab let g:lasttab = 1 -nmap <leader>tl :exe "tabn ".g:lasttab<CR> +nnoremap <leader>tl :exe "tabn ".g:lasttab<cr> 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 <leader>te :tabedit <C-r>=expand("%:p:h")<cr>/ +noremap <leader>te :tabedit <C-r>=expand("%:p:h")<cr>/ " Switch CWD to the directory of the open buffer -map <leader>cd :cd %:p:h<cr>:pwd<cr> +noremap <leader>cd :cd %:p:h<cr>:pwd<cr> " 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 <M-j> mz:m+<cr>`z -nmap <M-k> mz:m-2<cr>`z -vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z -vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z +nnoremap <M-j> mz:m+<cr>`z +nnoremap <M-k> mz:m-2<cr>`z +vnoremap <M-j> :m'>+<cr>`<my`>mzgv`yo`z +vnoremap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z if has("mac") || has("macunix") - nmap <D-j> <M-j> - nmap <D-k> <M-k> - vmap <D-j> <M-j> - vmap <D-k> <M-k> + nnoremap <D-j> <M-j> + nnoremap <D-k> <M-k> + vnoremap <D-j> <M-j> + vnoremap <D-k> <M-k> 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 <leader>ss :setlocal spell!<cr> +noremap <leader>ss :setlocal spell!<cr> " Shortcuts using <leader> -map <leader>sn ]s -map <leader>sp [s -map <leader>sa zg -map <leader>s? z= +noremap <leader>sn ]s +noremap <leader>sp [s +noremap <leader>sa zg +noremap <leader>s? z= """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Misc """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Remove the Windows ^M - when the encodings gets messed up -noremap <leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm +noremap <leader>m mmHmt:%s/<C-v><cr>//ge<cr>'tzt'm " Quickly open a buffer for scribble -map <leader>q :e ~/buffer<cr> +noremap <leader>q :e ~/buffer<cr> " Quickly open a markdown buffer for scribble -map <leader>x :e ~/buffer.md<cr> +noremap <leader>x :e ~/buffer.md<cr> " Toggle paste mode on and off -map <leader>pp :setlocal paste!<cr> +noremap <leader>pp :setlocal paste!<cr> " Disable F1 to open the help -map <F1> <Esc> -imap <F1> <Esc> +noremap <F1> <Esc> +inoremap <F1> <Esc> """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |