From 0637a2bcf54041df65565157c47250c695f754cc Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Sun, 26 Oct 2014 21:45:38 -0400 Subject: [PATCH] Improve diff mappings, alias :git == :vs but in vimdiff mode, fix some `/~ mappings that hadn't been changed, add c for tcomment (for keyboard without accessible modifiers), and configure tcomment to remove whitespace on uncomment --- vim/config/keyboard.vim | 37 ++++++++++++++++++++++--------------- vim/config/plugins.vim | 4 ++++ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/vim/config/keyboard.vim b/vim/config/keyboard.vim index fd4a779..8a49c3e 100644 --- a/vim/config/keyboard.vim +++ b/vim/config/keyboard.vim @@ -17,19 +17,15 @@ " :GitDiff & :gitdiff | (C) -> current file and last commit in vimdiff " :GitStatus & :gitstatus | (C) -> shows the output of git status " :GitCommit & :gitcommit | (C) -> commits changes to the current file +" :git | (C) -> open a vert split with the file in diff mode " :wsudo & :sudow | (C) -> write the file as root using sudo " :esudo & :sudoe | (C) -> read a file as root using sudo " " Reference: (view plugin documentation for the full list of commands each offers) -" (tcomment _ can also be -) " | (A) -> comment selection/create an empty comment -" gc | (A) -> comment selection/create an empty comment " b | (A) -> comment the current block(s) " r | (A) -> comment everything on the line to the right " p | (A) -> comment the current paragraph -" + | (V) -> increase the selected region -" _ | (V) -> decrease the selected region -" | (N) -> center content and hide everything else " " (surround) " S" | (V) -> surround selection with quotes @@ -149,7 +145,7 @@ " | (I) -> cut line before cursor during input " | (I) -> paste what's been cut during input " -" (completion) +" (autocompletion) " , | (A) -> enter after emmet 'word' (ie: html:5) " | (I) -> (neocomp) close the popup and " | (I) -> (neocomp) select/cycle popup completion @@ -166,6 +162,8 @@ " t | (N) -> convert tabs into spaces " T | (N) -> convert spaces into tabs " w | (N) -> remove whitespace +" c | (N) -> comment/uncomment current line +" c | (V) -> comment/uncomment selection " A | (N) -> aligns comments using the comment symbol " A | (V) -> aligns selected comments " a | (N) -> aligns all comments after text @@ -264,7 +262,9 @@ " " (vimdiff) " <> | (N) -> update differences +" ,. | (N) -> update differences " >< | (N) -> update differences +" ., | (N) -> update differences " > | (N) -> replace diff in other pane with current pane " . | (N) -> replace diff in other pane with current pane " replace diff in current pane with other pane @@ -313,6 +313,8 @@ cabbrev GitCommit ':Gcommit' cabbrev gitcommit ':Gcommit' + cabbrev diff ':vertical diffsplit' + cabbrev sudow SudoWrite cabbrev wsudo SudoWrite cabbrev sudoe SudoRead @@ -552,7 +554,7 @@ inoremap u "} - "COMPLETION:{ + "AUTOCOMPLETION:{ "emmet switch triggerkey from let g:user_emmet_leader_key='' @@ -589,6 +591,10 @@ "remove trailing whitespace nnoremap w ':FixWhitespace:echo "Trailing whitespace has been removed"' + "commant/uncomment current line/selection using tcomment + nmap c gcc + vmap c gc + "align comments nnoremap A :exe "%Tabular" '/^[^'.matchstr(&commentstring, '[^%]*').']*\zs'.matchstr(&commentstring, '[^%]*').'.*':redraw! vnoremap A :exe "'<,'>Tabular" '/^[^'.matchstr(&commentstring, '[^%]*').']*\zs'.matchstr(&commentstring, '[^%]*').'.*':redraw! @@ -713,12 +719,14 @@ autocmd FileType qf map ':call ToggleQuickfixList()' "vimdiff - autocmd FilterWritePre * if &diff|nnoremap <> ':diffu'|endif - autocmd FilterWritePre * if &diff|nnoremap >< ':diffu'|endif - autocmd FilterWritePre * if &diff|nnoremap > dp|endif - autocmd FilterWritePre * if &diff|nnoremap . dp|endif - autocmd FilterWritePre * if &diff|nnoremap < do|endif - autocmd FilterWritePre * if &diff|nnoremap , do|endif + autocmd FilterWritePre * if &diff|nmap <> ':diffu'|endif + autocmd FilterWritePre * if &diff|nmap ,. ':diffu'|endif + autocmd FilterWritePre * if &diff|nmap >< ':diffu'|endif + autocmd FilterWritePre * if &diff|nmap ., ':diffu'|endif + autocmd FilterWritePre * if &diff|nmap > dp|endif + autocmd FilterWritePre * if &diff|nmap . dp|endif + autocmd FilterWritePre * if &diff|nmap < do|endif + autocmd FilterWritePre * if &diff|nmap , do|endif autocmd FilterWritePre * if &diff|cabbrev q! qall!|endif "vimfiler @@ -729,12 +737,11 @@ autocmd FileType vimfiler map l autocmd FileType vimfiler map h autocmd FileType vimfiler map ' e - autocmd FileType vimfiler map ~ q "}}} "MAPPINGS DISABLED FOR GIVEN FILETYPES: {{{ "remove incompatible toggles from specific file types - autocmd Filetype qf,gundo,vimfiler,tagbar,extradite,help noremap ~ + autocmd Filetype qf,gundo,vimfiler,tagbar,extradite,help noremap ` autocmd Filetype qf,vimfiler,extradite,help noremap autocmd Filetype qf,vimfiler,extradite,help noremap autocmd Filetype gundo,vimfiler,extradite,help noremap diff --git a/vim/config/plugins.vim b/vim/config/plugins.vim index 427b42b..b32e58c 100644 --- a/vim/config/plugins.vim +++ b/vim/config/plugins.vim @@ -215,6 +215,10 @@ let g:tcommand#include_history=0 "}}} +"TCOMMENT: {{{ + let g:tcomment#rstrip_on_uncomment=2 "remove right-hand whitespace from all lines on uncomment +"}}} + "VIM FILER: {{{ "autostart filer when vim opens to an empty buffer (default: 1) if !exists("g:autostartfiler")|let g:autostartfiler=1|endif