From 4873abd09ce8940a2e3f2e0b0d496820a78dba5a Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Mon, 18 Jan 2016 15:49:58 -0500 Subject: [PATCH] Add find and replace to vim --- vim/spell/en.utf-8.add | 3 ++ vim/spell/en.utf-8.add.spl | Bin 1055 -> 1092 bytes vimrc | 66 ++++++++++++++++++++++++++----------- 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/vim/spell/en.utf-8.add b/vim/spell/en.utf-8.add index cf28f5e..40dbf2e 100644 --- a/vim/spell/en.utf-8.add +++ b/vim/spell/en.utf-8.add @@ -83,3 +83,6 @@ youtube HD playlists refactor +rebasing +Workflow +wiki diff --git a/vim/spell/en.utf-8.add.spl b/vim/spell/en.utf-8.add.spl index f5ae89b398a902aedb7e68f4f3c3e7f627fa3a03..cbd1c0ca6c8db0b5fc2eb1ab9a128e306b6116a0 100644 GIT binary patch literal 1092 zcmYLI%Z}7A5Oh0P{(xh|A&TaXwBin27PJ!5A|#G^IEiN*C&bA-Zu+d> zpt_v}jS_pRyQ{0(&X>FUFd64w|4~Z+epyy^W7@8_`@xUX9G3NXx+K%QYCDlm6SWIO zN)>^WtQ{>h(nO9*x{zgT=My)sK(WuexE2mEM-4Jds-^Ofx-l$?-H%$QH60MBkiz6f ztDsdys}wQP&>sJ0GFs~Zf*Fwst@R^$YNf06&Z4@r=Az1^bsLUQ;3*(^21V?>&_D)A z&z0-=FSc+Ku3ZgYZ>&}|WX+tFH{|sFe23`4hTT3SZ@s%rD@RpbdGZ`T2y#c zkEq*o(o+C(0i%sYuNHLT=?O*7Gvp3@MdY-vr8e_TS+#ybBJS;hFDr;{nWz?OZa5<< zQ!AqZw`rQv+AbH}Bjv?XXT*nQz5~#C-LmQtD&+ t?(Wl9N!h+6dVu%m??^!}yN`F`J$uOBqSOD;e-P|Js6Pue=NM2c^%tmD$?5m5MNwrkorh^YLu{*DITGK586;hbo zXce@oXptgD8rtFCOh#)RKrkaRL0aFDqgGT!JKNkHH5XMTt=q7N14jYLGblFgNFx~_ zJy%BmFBVyZYoo#ImDQ?-t(mj(hMfL}O|eIkVd&+OmX;B>=z0KFLCT{Ot+z%#RMgP{ zDrPHK2RPw^IxUU$EVT9`T50jHQp5_kT7h8{R0gtcUKg%iSp;j-rFdtJ@!S}za&VEx zDj?#pIDis(J|%enXz;oiUD6B@@gtrFKY;fYgt4{`7_(ttOz6{X`!zf=mJc<;WFtm7 zqtwipJ3!q20RbkFd1aL(ivRo)aWV4SB8O)m&Nl%^%}fmdtl9Cg=?6bEblm1%w5V{X z_Nd!&(tQAO0;AoEo<}J0^n@bk8L|Rj5jpL()Mif0)=kL6wcYVut%Z?wW}q^xubc1T zY-LJo8&A4N&i8Y-(x9t^}$jHt|G z!skm^oOFe{%!+gFQ$H=y0Z)~CVGSGV2ZZHu4@RiUt8hrRh g6iji8+j+lbqt9N0?*CZd33e^ipM{!p45*d*3!B8kJ^%m! diff --git a/vimrc b/vimrc index d034efa..1284d99 100644 --- a/vimrc +++ b/vimrc @@ -19,6 +19,7 @@ Plug 'tpope/vim-classpath' " Plug 'Valloric/YouCompleteMe' Plug 'rking/ag.vim' Plug 'scrooloose/syntastic' +Plug 'nelstrom/vim-qargs' " Colors Plug 'reedes/vim-colors-pencil' @@ -128,11 +129,9 @@ imap " Notes and other helpers map bb :!bundle install -map gs :Gstatus -map gw :!git add . && git commit -m 'WIP' map pn :sp ~/.personal-files/brain/writing/stack.txt map sn :sp ~/.personal-files/documents/software-notes/clojure.md -map rn :sp ~/.personal-files/work/dive-networks/files/notes/refactoring-notes.md +map rn :sp ~/.work-files/dive-networks/files/notes/refactoring-notes.md """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" @@ -196,6 +195,51 @@ augroup END """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%) +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" GIT +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +map gb :Gblame + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" SEARCHING +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +map gs :let @/ = "" + +" Replace the selected text in all files within the repo +function! GlobalReplaceIt(confirm_replacement) + if exists(':Ggrep') + " let term = @/ + " if empty(term) + call inputsave() + let term = input('Enter search term: ') + call inputrestore() + " else + " echo '\nReplacing '.term + " endif + call inputsave() + let replacement = input('Enter replacement: ') + call inputrestore() + if a:confirm_replacement + let confirm_opt = 'c' + else + let confirm_opt = 'e' + endif + execute 'Ggrep '.term + execute 'Qargs | argdo %s/'.term.'/'.replacement.'/g'.confirm_opt.' | update' + else + echo "Unable to search since you're not in a git repo" + endif +endfunction +map gg :call GlobalReplaceIt(0) +map gr :call GlobalReplaceIt(1) + +function! Search() + let term = input('Grep search term: ') + if term != '' + exec 'Ag "' . term . '"' + endif +endfunction +map s :call Search() """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " MISC KEY MAPS @@ -264,9 +308,6 @@ map map m :vsplit map mm :split -map gg :topleft 100 :split Gemfile -map gr :topleft 100 :split config/routes.rb - " Map paste and nonumber map p :set paste! paste? map o :set number! number? @@ -318,19 +359,6 @@ function! RenameFile() endfunction map n :call RenameFile() - -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" GREP SEARCH -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -function! Search() - let term = input('Grep search term: ') - if term != '' - exec 'Ag "' . term . '"' - endif -endfunction -map s :call Search() - - """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " PROMOTE VARIABLE TO RSPEC LET """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""