Last active
August 4, 2019 05:16
-
-
Save TroyFletcher/b1f4795e010049e8087322dd0a7960bf to your computer and use it in GitHub Desktop.
Proverbial VimRC. NOT copied from anyone else. Perhaps there's some trick you might use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" git clone https://gist.github.com/b1f4795e010049e8087322dd0a7960bf.git | |
set nocompatible " This must be first... BECAUSE REASONS... | |
let mapleader = "\<Space>" | |
let maplocalleader = "\<Space>" | |
set t_Co=256 | |
set laststatus=2 " For airline | |
filetype off | |
" set the runtime path to include Vundle and initialize | |
"set rtp+=~\Downloads\vimwin\bundle\Vundle.vim | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required | |
Plugin 'VundleVim/Vundle.vim' | |
Plugin 'easymotion/vim-easymotion' | |
Plugin 'tpope/vim-surround' | |
Plugin 'vim-airline/vim-airline' | |
Plugin 'vim-airline/vim-airline-themes' | |
Plugin 'chrisbra/csv.vim' | |
Plugin 'altercation/vim-colors-solarized' | |
Plugin 'whatyouhide/vim-gotham' | |
Plugin 'michaeljsmith/vim-indent-object' | |
Plugin 'tpope/vim-vividchalk' | |
Plugin 'tomasr/molokai' | |
" Plugin 'twe4ked/vim-colorscheme-switcher' | |
Plugin 'kreeger/benlight' | |
Plugin 'adlawson/vim-sorcerer' | |
" Plugin 'sirtaj/vim-openscad' | |
"Plugin 'kana/vim-fakeclip' | |
"Plugin 'w0rp/ale' | |
Plugin 'tpope/vim-fugitive' | |
call vundle#end() " required | |
filetype plugin indent on " required | |
" the proceeding maps use a hack for inline comments. | |
" The pipe terminates the last command (the map in this case) and " is a comment | |
let g:EasyMotion_do_mapping = 0 " Disable default mappings | |
" Bi-directional find motion | |
" Jump to anywhere you want with minimal keystrokes, with just one key binding. | |
" `s{char}{label}` | |
nmap s <Plug>(easymotion-s) | |
nmap <leader>f <Plug>(easymotion-f) | |
nmap <leader>F <Plug>(easymotion-F) | |
nmap <leader>t <Plug>(easymotion-t) | |
nmap <leader>T <Plug>(easymotion-T) | |
" or | |
" `s{char}{char}{label}` | |
" Need one more keystroke, but on average, it may be more comfortable. | |
"nmap s <Plug>(easymotion-s2) | |
" Turn on case insensitive feature | |
let g:EasyMotion_smartcase = 1 | |
" JK motions: Line motions | |
"map <Leader>j <Plug>(easymotion-j) | |
"map <Leader>k <Plug>(easymotion-k) | |
"Solarized config | |
set background=dark | |
colorscheme solarized | |
" feeling out some different color schemes, plus some notes | |
colorscheme molokai | |
colorscheme benlight | |
colorscheme sorcerer | |
"colorscheme gotham | |
"colorscheme gotham | |
"colorscheme vividchalk | |
"elflord contrasty purple and VERY blue. tasstes like candy. probably good in the dark | |
" | |
"dracula muted purple/blue, good light | |
"vividchalk high contrast purple blue | |
" koehler muted good contrast purple/blue, good dark | |
" | |
"sorcerer earthy, very muted, great light | |
"benlight muted earth tones good bright, maybe too muted, no whites... try it dark... | |
" | |
"gotham dark the theme you deserve | |
" General | |
"slate the old standby | |
"pablo good generalist, mid contrast, maybe better dark | |
" molokai it's just nice. | |
"torte muted purple/pink/orange dark background | |
" industry pretty nice low light but colorful | |
"material like a brighter gotham Like it! | |
" desert very cool, maybe too pastelle | |
syntax on | |
set hlsearch | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline_powerline_fonts = 1 | |
" Append total line count after current line number on default airline statusline (IE: from 12 to 12/34) | |
function! AirlineInit() | |
let g:airline_section_z = '%3p%% %{g:airline_symbols.linenr}%#__accent_bold#%4l%#__restore__#/%L:%3v' | |
endfunction | |
autocmd VimEnter * call AirlineInit() | |
let g:airline_theme="molokai" | |
"AirlineTheme solarized | |
"AirlineTheme durant | |
"AirlineTheme understated | |
"AirlineTheme tomorrow | |
"AirlineTheme kalisi | |
"AirlineTheme gotham256 | |
"AirlineTheme monochrome | |
" Speeding things up | |
"======================================================================= | |
"map <C-j> 15j|"Useful for jumping the cursor around -- NOPE easymotion is easier (below) | |
"map <C-k> 15k|"Useful for jumping the cursor around -- NOPE easymotion is easier (below) | |
map <C-j> <Plug>(easymotion-j) | |
map <C-k> <Plug>(easymotion-k) | |
map <C-l> :bn!<cr>|"Next buffer | |
map <C-h> :bp!<cr>|"Previous buffer | |
map _ <C-w>_|"(underscore) quickly expand current window to max, squish all other splits | |
map <leader>j <C-w>j<C-w>_|"Switch to split below, and expand to full size (great for horizontal splits) | |
map <leader>k <C-w>k<C-w>_|"Switch to split above, (see above) | |
imap jk <Esc>|"Exit insert mode with bigram unused in english: jk. Others: jd jf jk jl fk js | |
cmap jk <C-r>|"In command mode use bigram to quickly Control-R and await registry key to put | |
imap jK <Esc>la|"Go forward a character without leaving insert mode | |
imap jH <Esc>i|"Go back one character without leaving insert mode | |
map <leader>o o<Esc>|"Add a line below cursor and STAY OUT OF INSERT MODE! | |
map <leader>O O<Esc>|"Add a line above cursor and STAY OUT OF INSERT MODE! | |
"Don't use the arrow keys... for moving the cursor | |
nmap <Up> ddkP|"Move current line up | |
nmap <Down> ddp|"Move current line down | |
nmap <Left> <<|"Move the line to the left (indentwise) | |
nmap <Right> >>|"Move the line to the right (indentwise) | |
vmap <Left> <gv|"Move visual linemode selected lines left | |
vmap <Up> dkP`[V`]|"Move visual linemode selected text up | |
vmap <Down> dp`[V`]|"Move visual linemode selected text down | |
vmap <Right> >gv|"Move visual linemode selected lines right | |
set incsearch " highlight matches as you type. see matches faster, catch typos | |
set hidden " get rid of dumb message when switching from buffers that are not saved | |
nnoremap gp `[v`] | |
"======================================================================= | |
" Leader key madness | |
"======================================================================= | |
"vnoremap <leader>c "+y|"yank to system clipboard | |
"map <leader>A ggVG"+y|"yank whole file to system clipboard | |
" | |
" vim tmux clipboard sharing on systems lacking gui clipboards (xsel,xclip,X) | |
" https://gist.github.com/FletchINK/f1e7f572cbcfbad3d88e | |
vmap <cr> "zy:silent! call SendZBufferToHomeDotClipboard()<cr>|"area highlighted by mouse drag, hit secondary button <enter> copy to system clipboard | |
vnoremap <leader>c "zy:silent! call SendZBufferToHomeDotClipboard()<cr>|"yank to z clipboard | |
map <leader>v :silent! call HomeDotClipboardPut()<cr>|"Paste from system clipboard | |
"map <leader>v "+p|"Paste from system clipboard | |
map <leader>A ggVG"zy:silent! call SendZBufferToHomeDotClipboard()<cr>|"yank whole file to z clipboard | |
"!tmux paste-buffer | |
"imap <c-v> <Esc>"+pA|"Past from system clipboard in insert mode |"c-v is too useful to remap | |
map <leader>p :b!#<cr>|"Switch to previous buffer | |
map <leader>b :ls<CR>:b!<Space>|"show buffer list and type in buffer name/number to switch | |
map <leader>e bexwP|"I typo my space lik ethis, so put cursor on the e and repair the typo | |
inoremap <C-U> <C-G>u<C-U>|"Idunnolol | |
"======================================================================= | |
" Annoyances | |
"======================================================================= | |
nmap <silent> <leader>a :nohlsearch<CR>|"stop typing /asdfasdf to clear search highlighting | |
set splitbelow " open new splits below current | |
set splitright " open new splits to the right current | |
set backspace=indent,eol,start | |
set virtualedit=block " allow block selections to extend beyond entered text (floating selection) | |
set tm=700 | |
set wildmenu | |
set mouse=ni " The mice who say NI! Enter visual mode to putty drag select to copy to local clip. Otherwise scroll freely | |
set wildmode=longest:list,full | |
set lazyredraw | |
"hurr durr just press zz. As usual, vim has already thought of it and incorporated it perfectly... | |
"map <silent> <C-c> mm15j'm15k`mV:sleep 150m<CR>`m|"center screen on cursor and highlight for 150ms | |
map <silent> <C-c> myzzV:sleep 150m<CR>`y|"center screen on cursor and highlight for 150ms | |
map <leader>l $|" Because the 4 key is WAAAAYYYYY up there... | |
map <leader>h 0|" Because the 0 key is off the home row... | |
map <leader>V 0v$h|"visually select the whole line excluding the newline | |
vmap <leader>V $h|"visually select from position to end of line excluding the newline | |
"nnoremap ; :|"As soon as I did this I realized how often I used semi-colon... | |
"nnoremap : ;|"HA! Breaks every command that uses colon. Not worth the redo or trouble. nevermind. | |
hi Folded ctermbg=NONE|"brightly highlighted folds on a dark color scheme are distracting | |
"set showbreak=~>|" show line breaks as ~>. Unicode characters can be iffy in console. | |
set showbreak=»|"Unicodin' | |
"Below meant to be used in conjunction with [s and ]s to skip around and do a first suggestion replace | |
map [f 1z=|"On current word, replace word with first spellcheck suggestion | |
map ]f 1z=|"On current word, replace word with first spellcheck suggestion | |
noremap <C-e> 3<C-e>|"Change scroll page up one line to scroll page 3 lines | |
noremap <C-y> 3<C-y>|"Change scroll page down one line to scroll page 3 lines | |
vnoremap . :norm.<CR>|" YES! Repeat function on each visually selected line! | |
map <C-n> :norm n.<cr>|"search forward for the next match and repeat last command (command so count-able) | |
map <C-q> @@|"Control q to repeat last macro. | |
imap <C-y> @@@<ESC>hhkyWjl?<BS><BS>@@@<CR>gnPa|"Press Ctrl-Y copies word from above line instead of character | |
imap <C-BS> <C-W>|"Delete previous word in insert mode with control backspace as in most OSs | |
cmap <C-BS> <C-W>|"Delete previous word in command mode with control backspace as in most OSs | |
"======================================================================= | |
" Useful Macros | |
"======================================================================= | |
" run command in this line in the window on the left and come back | |
"map <leader>qch ^v$hyh:jk" l | |
map <silent> <leader>qch ^v$hy<C-w>h:jk"<cr><C-w>l:nohlsearch<cr>|"run command on this line in left buffer | |
map <silent> <leader>qcl ^v$hy<C-w>l:jk"<cr><C-w>h:nohlsearch<cr>|"run command on this line in right buffer | |
map <silent> <leader>qck ^v$hy<C-w>k:jk"<cr><C-w>j:nohlsearch<cr>|"run command on this line in up buffer | |
map <silent> <leader>qcj ^v$hy<C-w>j:jk"<cr><C-w>k:nohlsearch<cr>|"run command on this line in down buffer | |
map <leader>qt kmyjddggP`y|"Move this line to the top | |
vmap <leader>qt <ESC>`<kmygvdggP'y | |
map <leader>qb jmykddGp`y|"Move this line to the bottom | |
vmap <leader>qb <ESC>`<kmygvdGP'y|"Move this line to the bottom VISUAL | |
map <leader>qf :g/./m0<cr>:nohlsearch<cr>|"Flip file lines beginning to end | |
map <leader><leader> :set cul! cuc!<cr>|"Toggle cursor crosshair. Great when you get a big monitor and you're jumping around. | |
map <leader>qw :set wrap!<cr>|"toggle wordwrap | |
map <leader>qss :sort<cr>|"sort | |
map <leader>qsS :sort!<cr>|"sort reverse order | |
map <leader>qsu :sort u<cr>|"sort unique | |
map <leader>qu :%!uniq -c<cr>|"uniq count | |
map <F10> :setlocal paste!<cr>:echo "toggle paste"<cr> | |
map <F11> :setlocal spell!<cr>:echo "toggle spell"<cr> | |
map <leader>DT :!dropbox status<cr> | |
map <leader>DS :!dropbox stop<cr> | |
map <leader>DG :!dropbox start<cr> | |
" Speeding up coding | |
"======================================================================= | |
map <leader>/ yiw/<C-r>"<cr>|"yank inside word search back for this word (for special methods/variables) | |
map <leader>? yiw?<C-r>"<cr>|"Same as above but search back | |
vmap <leader>/ y/<C-r>"<cr>|"yank visual selection and search back for this word (for special methods/variables) | |
vmap <leader>? y?<C-r>"<cr>|"Same as above but search back | |
" super search for visually selected text across windows | |
map <silent> <leader>S yiw:silent! windo /<C-r>"<cr>|"Yank this word and search in all windows | |
vmap <silent> <leader>S y:silent! windo /<C-r>"<cr>|"Yank this visual selection and search in all windows | |
map <silent> <leader>s y:silent! windo /<C-r>"<cr>|"Yank this line and search in all windows | |
map <leader>d yiw/def <C-r>"<cr>|"yank inside word at the position, find function with "def $word" | |
" Would make a mark, but you can jump back after this with Control+o | |
map <leader>x ^i# jkh|"Comment a line (uses "# " at first non-whitespace character) | |
map <leader>X ^xx|"UNcomment a line that was commented above | |
vmap <leader>x :norm ^i# <CR>|"Comment visually selected lines (at ^) | |
vmap <leader>X :norm ^xx<CR>|"Comment visually selected lines (at ^) | |
nnoremap <leader>n :setlocal relativenumber!<cr>|"toggle relative line numbers for movement/visual selections | |
noremap <leader>N :setlocal number!<cr>|"toggle line numbers to save precious screen real estate | |
" Tab / indent behavior, Currently set for python | |
"======================================================================= | |
set tabstop=8 | |
set expandtab | |
set softtabstop=4 | |
set shiftwidth=4 | |
filetype indent on | |
"set textwidth=79 " lines longer than 79 columns will be broken | |
set shiftround " round indent to multiple of 'shiftwidth' | |
set autoindent " align the new line indent with the previous line | |
set hlsearch | |
set spelllang=en_us | |
" Settings | |
"======================================================================= | |
set undofile " undo files are brilliant. git them everywhere... | |
set wildignore=*.swp,*.bak,*.pyc,*.class " don't show filetypes in wildcard file search autocompletion | |
set textwidth=107 | |
nnoremap / /\v | |
nnoremap ? ?\v | |
vnoremap / /\v | |
vnoremap ? ?\v | |
" Stop hitting F1 by mistake... "Kinda pointless since imap jk <esc> | |
inoremap <F1> <ESC> | |
nnoremap <F1> <ESC> | |
vnoremap <F1> <ESC> | |
map <F3> mmggg?G`m|"Secret squirrel! | |
imap <F3> <ESC>mbggg?G`ba|"Insert mode secret squirrel! Kinda neat to write spoilers in line | |
" function! FixLastSpellingError() | |
" normal! mm[s1z=`m | |
" endfunction | |
" nnoremap <leader>sp :call FixLastSpellingError()<cr> | |
"Example/skeleton function | |
"function! FunctionNameHere() | |
" silent! set command=things | |
" silent! %s/stuff/things/ge | |
" silent! normal ggg?G | |
" silent! v/lineswithoutthistext/d[elete them] | |
" silent! normal gg | |
"endfunction | |
"command! FunctionShortName call FunctionNameHere() | |
function! ChangeSqlDateToStandard() | |
"01-DEC-2009 00:00:01 into 12-1-2009 | |
silent! %g/\s/normal f d$ | |
silent! %s/JAN/01/ge | |
silent! %s/FEB/02/ge | |
silent! %s/MAR/03/ge | |
silent! %s/APR/04/ge | |
silent! %s/MAY/05/ge | |
silent! %s/JUN/06/ge | |
silent! %s/JUL/07/ge | |
silent! %s/AUG/08/ge | |
silent! %s/SEP/09/ge | |
silent! %s/OCT/10/ge | |
silent! %s/NOV/11/ge | |
silent! %s/DEC/12/ge | |
silent! g/./normal 0wwd3l0P | |
silent! %s/-/\//g | |
silent! %s/^0//g | |
silent! %s/\/0/\//g | |
endfunction | |
command! SqlDateToStandard call ChangeSqlDateToStandard() | |
function! TabSeparatedToCommaSeparated() | |
silent! exe "%s/\<Tab>/\",\"/g" | |
silent! %s/^/"/g | |
silent! %s/$/"/g | |
silent! set ft=csv | |
endfunction | |
command! TSV2CSV call TabSeparatedToCommaSeparated() | |
function! CustomerProfileToPythonInput() | |
silent! norm ggyG | |
silent! %s/\v^[^\t]+\t[^\t]+\t[^\t]+\t([^\t]+)\t[^\t]+\t[^\t]*\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+$/lf_profiles['\1'] = {'Activity' : {}, 'Contact' : {}, 'Readings' : {}}/g | |
silent! sort u | |
silent! norm Gp | |
silent! .,$s/\v^[^\t]+\t[^\t]+\t[^\t]+\t([^\t]+)\t[^\t]+\t[^\t]*\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)\t([^\t]+)$/lf_profiles['\1']['\2']['\3']={'Required for Outbound':'\4','Required for Inbound':'\5','Confirm':'\6','Update Asset':'\7'}/g | |
silent! norm GojkggOlf_profiles={}jkgg"+yG | |
echo "Copied python script to system clipboard." | |
endfunction | |
command! CustProfileToPython call CustomerProfileToPythonInput() | |
function! VerticalSplitJoinToCSV() | |
" FOR USE WHILE DIFF-ING because it will not match line numbers otherwise | |
silent! g/./ exe "norm A,\<esc>\<c-w>l0y$\<c-w>h$p" | |
"silent! exe "norm \<c-w>q" | |
silent! normal gg | |
endfunction | |
command! VertSplitJoin call VerticalSplitJoinToCSV() | |
function! BlockHighlightToSearchCommand() | |
silent! norm vip | |
silent! %s/$/\|/g | |
silent! :norm gvgJ | |
silent! :norm $r/ | |
silent! :norm Imatch search /\vjk0 | |
endfunction | |
command! BlockHighlight call BlockHighlightToSearchCommand() | |
function! SendZBufferToHomeDotClipboard() | |
" Yank the contents buffer z to file ~/.clipboard | |
" For use with HomeDotClipboardPut() | |
silent! redir! > ~/.clipboard | |
silent! echo @z | |
silent! redir END | |
" the redir has a newline in front, so tail -n+2 skips first line | |
silent! !tail -n+2 ~/.clipboard > ~/.clipboard.1;mv ~/.clipboard.1 ~/.clipboard | |
silent! !tmux load-buffer ~/.clipboard | |
silent! !cat ~/.clipboard | nc 127.0.0.1 11311 & | |
silent! redraw! | |
" pwd | |
" ls | |
" clear | |
endfunction | |
function! HomeDotClipboardPut() | |
" Paste/Put the contents of file ~/.clipboard | |
" For use with SendZBufferToHomeDotClipboard() | |
silent! !tmux save-buffer ~/.clipboard | |
silent! redraw! | |
silent! let @z = system("cat ~/.clipboard") | |
" put the z buffer on the line below | |
silent! exe "norm o\<ESC>\"zp" | |
endfunction | |
vmap <C-y> y:new ~/.clipboard<CR>VGp:x<CR>|"the smartest way to accomplish what should be easy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment