commit fe12003629a9a87105ded2da2bd83ab9d2f32777 (patch)
parent 795e2b0e80c8fd79ef4bd20ee4200ca4deffb016
Author: Alexander Karle <akarle@umass.edu>
Date: Sun, 25 Nov 2018 23:04:35 -0500
vim: Minor improvements to commands and mappings
1. <C-p> now pastes unformatted from clipboard (instead of toggling
paste). I found myself only using paste-toggle to paste from clipboard,
so here we are...
2. :GitGrep now opens the quickfix window after calling. Previously it
was hard to tell when it was done
Diffstat:
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/vim/vimrc b/vim/vimrc
@@ -188,6 +188,12 @@ function! s:InGitRepo() abort
return 0
endfunction
+function! SetPasteAndPasteFromClipboard() abort
+ set paste
+ normal! "*p
+ set nopaste
+endfunction
+
function! s:warn(msg) abort
echohl WarningMsg
echo 'vimrc: ' . a:msg
@@ -215,13 +221,11 @@ if has('terminal') || has('nvim')
tnoremap <C-W> <C-\><C-N><C-W>
endif
-"Map ctrl-p to toggle paste mode
-nnoremap <C-p> :set paste!<CR>
+" Paste from clipboard without any formatting issues
+nnoremap <C-p> :call SetPasteAndPasteFromClipboard()<CR>
-" Elim Whitespace (through regexp)
+" Clear trailing whitespace (through regexp)
nnoremap <leader><space> :call CMDPreserve("%s/\\s\\+$//e")<CR>
-" save session
-" nnoremap <leader>s :mksession!<CR>
" edit in current buffer dir
nnoremap <leader>e :e %:h/
@@ -266,7 +270,7 @@ nnoremap <leader>y gg"*yG<C-O><C-O>
" }}}
" COMMANDS {{{
-command! -nargs=1 GitGrep call GitGrep('<args>')
+command! -nargs=1 GitGrep call GitGrep('<args>') | copen
command! CD exe 'cd ' . expand('%:h')
" }}}