From 308694fee165ea438f3eb5a2b6438627675b5e1f Mon Sep 17 00:00:00 2001 From: Caleb Taylor Date: Tue, 6 Aug 2019 15:51:11 -0700 Subject: [PATCH] added more maps and edited a few maps --- vimrcs/basic.vim | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/vimrcs/basic.vim b/vimrcs/basic.vim index 11d1ed81..380aa212 100644 --- a/vimrcs/basic.vim +++ b/vimrcs/basic.vim @@ -42,7 +42,7 @@ set autoread " With a map leader it's possible to do extra key combinations " like w saves the current file -let mapleader = "," +let mapleader = " " " Fast saving nmap w :w! @@ -203,6 +203,10 @@ vnoremap # :call VisualSelection('', '')?=@/ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Moving around, tabs, windows and buffers """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Treat long lines as break lines (useful when moving around in them) +map j gj +map k gk + " Map to / (search) and Ctrl- to ? (backwards search) map / map ? @@ -269,9 +273,41 @@ set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Editing mappings """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Remap VIM ESC to normal mode from insert mode using jj +" only issue when you need to literally type two jj's in insert mode therefore you must type slowly +imap jj + +" Just like traditional Select All, Ctrl+a +map ggVG + " Remap VIM 0 to first non-blank character map 0 ^ +" Remap VIM H to first non-blank character +map H ^ +" Remap VIM L to last blank character +map L $ + +" Clears highlighting +map :noh + +" Replace word by occurence, press '.' to move to the next occurence which auto replaces with new word. I use it to rename variables. So far I haven't found a mapping that does it by scope reliably like vscode. +nnoremap gr *``cgn + + +" This loop remaps all 'alt key + character' to '\e + character' +" On my vim(windows, but some other windows users didn't have a problem) +" it won't recognize the Meta key when Alt is pressed +" https://vi.stackexchange.com/questions/2350/how-to-map-alt-key/2363 + +" for i in range(97,122) +" let c = nr2char(i) +" execute "set =\e".c."" +" " On the 'j' iteration it would look like this +" " --> execute \"set =\ej" +" endfor + " Move a line of text using ALT+[jk] or Command+[jk] on mac nmap mz:m+`z nmap mz:m-2`z @@ -299,6 +335,13 @@ if has("autocmd") endif + +" These two mappings are a quality of life improvement of copy/pasting from the clipboard +" Effectively this paste map applies the indent within the pasted content from the indent level that you're at when you invoke the pasting +" http://tilvim.com/2014/03/18/a-better-paste.html +map p :set pasteo"*]p:set nopaste +vmap y "+y + """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Spell checking """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -325,7 +368,7 @@ map q :e ~/buffer map x :e ~/buffer.md " Toggle paste mode on and off -map pp :setlocal paste! +" map pp :setlocal paste! """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""