" File: vimrc " " Author: created by reedes on 16-Feb-2013 " Updated: continuously " URL: https://github.com/reedes/vim-config set nocompatible " # VUNDLE (package management) filetype off set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " let vundle manage itself Bundle 'gmarik/vundle' " # Non-color Bundles "Bundle 'roman/golden-ratio' "Bundle 'ervandew/supertab' Bundle 'Lokaltog/vim-easymotion' Bundle 'tommcdo/vim-exchange' Bundle 'airblade/vim-gitgutter' Bundle 'kana/vim-textobj-user' "Bundle 'kana/vim-operator-user' Bundle 'kien/ctrlp.vim' "Bundle 'mileszs/ack.vim' "Bundle 'milkypostman/vim-togglelist' Bundle 'moll/vim-bbye' Bundle 'scrooloose/nerdtree' Bundle 'tpope/vim-markdown' "Bundle 'plasticboy/vim-markdown' "Bundle 'bling/vim-airline' "Bundle 'rhysd/vim-operator-surround' "Bundle 'tpope/vim-repeat' "Bundle 'tpope/vim-abolish' "Bundle 'tpope/vim-unimpaired' Bundle 'junegunn/vader.vim' " # Authored Bundles Bundle 'reedes/vim-colors-pencil' Bundle 'reedes/vim-lexical' Bundle 'reedes/vim-litecorrect' Bundle 'reedes/vim-one' Bundle 'reedes/vim-pencil' Bundle 'reedes/vim-textobj-quote' Bundle 'reedes/vim-textobj-sentence' Bundle 'reedes/vim-thematic' Bundle 'reedes/vim-wheel' Bundle 'reedes/vim-wordy' " # Color Bundles Bundle 'hmaarrfk/vim-colors-solarized' Bundle 'baskerville/bubblegum' Bundle 'chriskempson/base16-vim' Bundle 'endel/vim-github-colorscheme' Bundle 'nanotech/jellybeans.vim' Bundle 'noahfrederick/vim-hemisu' syntax enable filetype plugin indent on set autoindent set backspace=indent,eol,start set complete-=i set smarttab set nrformats-=octal set shiftround set ttimeout set ttimeoutlen=100 set incsearch " Use to clear the highlighting of :set hlsearch. if maparg('', 'n') ==# '' nnoremap :nohlsearch endif set ruler set showcmd set wildmenu if !&scrolloff set scrolloff=1 endif if !&sidescrolloff set sidescrolloff=5 endif set display+=lastline if &encoding ==# 'latin1' && has('gui_running') set encoding=utf-8 endif if &listchars ==# 'eol:$' set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+ if !has('win32') && (&termencoding ==# 'utf-8' || &encoding ==# 'utf-8') let &listchars = "tab:\u21e5 ,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u00b7" endif endif if &shell =~# 'fish$' set shell=/bin/bash endif set autoread set fileformats+=mac if &history < 1000 set history=1000 endif if &tabpagemax < 50 set tabpagemax=50 endif if !empty(&viminfo) set viminfo^=! endif " Allow color schemes to do bright colors without forcing bold. if &t_Co == 8 && $TERM !~# '^linux' set t_Co=16 endif " Load matchit.vim, but only if the user hasn't installed a newer version. if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# '' runtime! macros/matchit.vim endif inoremap u imap ,fn =expand('%:t:r') " Make the 'cw' and like commands put a $ at the end " instead of just deleting the text and replacing it. set cpoptions+=$ " Don't update the display while executing macros set lazyredraw " Don't show the current command int he lower right corner. " In OSX, if this is set and lazyredraw is set then it's " slow as molasses, so we unset this "set noshowcmd " Various characters are "wider" than normal fixed width " characters, but the default setting of ambiwidth (single) " squeezes them into "normal" width, which sucks. "set ambiwidth=double " Add the unnamed register to the clipboard set clipboard+=unnamed set expandtab " use spaces, not tabs (optional) set hlsearch " highlight matches set ignorecase " searches are case insensitive... set laststatus=0 set list " show invisible characters set nowrap " don't wrap lines set shortmess=atI " suppress PRESS ENTER messages by shortening messages set smartcase " ... unless they contain at least one capital letter set synmaxcol=800 " Don't try to lines highlight longer than 800 characters. set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4) set visualbell " avoid beeping set hidden " allow unwritten background buffers if has('unix') set shell=/bin/bash\ -i " make Vim’s :! shell behave like your command prompt endif " Make the current file executable nmap ,x :w:!chmod 755 %:e " command-t, ctrlp config and expanding wildcards set wildignore+=*.*~ set wildignore+=*.bak set wildignore+=*.bz2,*.gz,*.tar,*.xz,*.zip set wildignore+=*.class,*.pyc,*.so set wildignore+=*.epub,*.mobi,*.pdf set wildignore+=*.png,*.jpg,*.gif set wildignore+=*.swp set wildignore+=.DS_Store set wildignore+=.git/** set wildignore+=.svn/** set wildignore+=log/** set wildignore+=tmp/** " get rid of cmd-t for tab "if has('gui_macvim') " macmenu File.New\ Tab key= "endif iab mdy =strftime("%B %d, %Y") iab mdyhm =strftime("%A %B %d, %Y %I:%M %p") iab isodate =strftime("%FT%T%z") let mapleader = "," " key instead of backslash (options '\_,;') " join, maintaining cursor position "nnoremap S i^mzgk:silent! s/\v +$//:noh`z "nnoremap J mzJ`z "nnoremap K :nohlsearch " select what was just pasted nnoremap gp '`[' . strpart(getregtype(), 0, 1) . '`]' augroup CursorLine au! au VimEnter,WinEnter,BufWinEnter * setlocal cursorline au WinLeave * setlocal nocursorline augroup END "set nocursorline "set nocursorcolumn "nnoremap Q gwip "nnoremap K vipJ "nnoremap ,Q :g/^/norm gqq "nnoremap ,K :%norm vipJ " For quick recordings just type qq to start recording, then q to stop. You " don't have to worry about the name this way (you just named the recording " 'q'). Now, to play back the recording you just type Q. "nnoremap Q @q "noremap @q "make clear the highlight as well as redraw noremap :nohlsearch inoremap :nohlsearch " Clean trailing whitespace and save "nnoremap ,w mz:%s/\s\+$//e:let @/=''`z:w nnoremap ,w :call TrimAndWrite() function! TrimAndWrite() let l:p = getpos('.') silent! %s/\s\+$//e call setpos('.', l:p) write endfunction " # Quick Editing - edit vimrc file and others " NOTE pointing to all files in vim dir so that can easily " browse directory using NERDTreeFind (T). nnoremap ,E :edit $MYVIMRC "nnoremap ,es :wall:so $MYVIMRC " Remember last location in file, but not for commit messages. " see :help last-position-jump augroup line_return au! au BufReadPost * \ if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$") | \ execute 'normal! g`"zvzz' | \ endif augroup END " automatically save all buffers when focus is lost autocmd FocusLost * :silent! wall "autowriteall " jump to the first open window that has buffer "set switchbuf=useopen " delete buffer without closing window (vim-bbye plugin) nmap :Bdelete " switch buffers ([b and ]b in unimpaired) nmap :bprevious nmap :bnext " switch buffers via quickfix ([q and ]q in unimpaired) nmap ,p :cpreviouszvzz nmap ,n :cnextzvzz nmap ,P :crewindzvzz nmap ,N :clastzvzz " switch buffers via location ([l and ]l in unimpaired) "nmap ,k :lpreviouszvzz "nmap ,j :lnextzvzz "nmap ,K :lrewindzvzz "nmap ,J :llastzvzz " # Common directories for backup, undo and swap set backup " enable backups set undofile " Save undo's after file closes set undolevels=1000 " How many undos set undoreload=10000 " number of lines to save for undo set backupdir=~/.vim/tmp/backup// " backups set undodir=~/.vim/tmp/undo// " undo files set directory=~/.vim/tmp/swap// " swap files " Make those folders automatically if they don't already exist. if !isdirectory(expand("~/.vim/tmp/backup")) call mkdir(expand("~/.vim/tmp/backup"), "p") endif if !isdirectory(expand("~/.vim/tmp/undo")) call mkdir(expand("~/.vim/tmp/undo"), "p") endif if !isdirectory(expand("~/.vim/tmp/swap")) call mkdir(expand("~/.vim/tmp/swap"), "p") endif " Close all folds except the one(1) the cursor is on, and center. nnoremap z1 zMzvzz " Make zO (not zero) recursively open whatever top level fold we're in, no " matter where the cursor happens to be, and center. nnoremap zO zCzOzz " Make horizontal scrolling easier "nmap 10zl "nmap 10zh " set styling on vertical splits (hard space) set fillchars=vert:  set splitbelow set splitright "let g:SuperTabDefaultCompletionType = "context" "highlight OverLength ctermbg=red ctermfg=white guibg=#592929 "match OverLength /\%81v.\+/ "call matchadd('ColorColumn', '\%81v', 100) "key mapping for Gundo "nnoremap :GundoToggle " "map ,e (easymotion-prefix) " let g:one#handleSwapfileConflicts = 1 " 0=disable, 1=enable (def) nmap ,v :wall:Vader let g:force_reload_textobj_sentence = 1 let g:litecorrect#typographic = 0 augroup various autocmd! autocmd FileType markdown,mkd \ call litecorrect#init() | \ call lexical#init() | \ call textobj#sentence#init() | \ call textobj#quote#init() | \ call pencil#init() autocmd FileType text \ call litecorrect#init() | \ call lexical#init({ 'spell': 0 }) | \ call textobj#sentence#init() | \ call textobj#quote#init() | \ call pencil#init() augroup END " Avoid loading of MatchParen, per pi_paren.txt "let loaded_matchparen = 1 "let g:wheel#map#mouse = -1 let g:lexical#spelllang = ['en_us',] let g:lexical#spell_key = ',u' let g:lexical#thesaurus_key = ',j' let g:lexical#dictionary_key = ',k' let g:pencil#softDetectSample = 40 let g:pencil#softDetectThreshold = 100 let g:pencil#wrapModeDefault = 'soft' let g:online_thesaurus_map_keys = 0 nnoremap ,r :OnlineThesaurusCurrentWord map ,c (ReplaceWithCurly) map ,s (ReplaceWithStraight) map ,2 (SurroundWithDouble) map ,1 (SurroundWithSingle) " operator mappings for rhysd/vim-operator-surround "map sa (operator-surround-append) "map sd (operator-surround-delete) "map sr (operator-surround-replace) " delete or replace most inner surround "" if you use vim-textobj-quote "nmap sdd (operator-surround-delete)(textobj-quote-a) "nmap srr (operator-surround-replace)(textobj-quote-a) " "" if you use vim-textobj-sentence "nmap sdd (operator-surround-delete)(textobj-sentence-a) "nmap srr (operator-surround-replace)(textobj-sentence-a) map :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" let g:pencil_neutral_headings = 1 let g:pencil_higher_contrast_ui = 0 nmap ,A :ShiftPencil nmap ThematicNarrow nmap ThematicWiden nmap ,y ThematicNext nmap ,Y ThematicRandom nmap ,I :Thematic pencil_dark " use jellybeans as default airline theme as it maps from " existing colors let g:thematic#defaults = { \ 'airline-theme': 'jellybeans', \ 'fullscreen-background-color-fix': 1, \ 'sign-column-color-fix': 1, \ 'laststatus': 0, \ 'background': 'dark', \ 'font-size': 20, \ 'linespace': 0, \ 'transparency': 0, \ } let g:thematic#themes = { \ 'desert' : { 'sign-column-color-fix': 1, \ 'columns': 80, \ 'lines': 30, \ 'linespace': 9, \ 'sign-column': 1, \ 'fold-column-color-mute': 1, \ 'number-column-color-mute': 1, \ 'typeface': 'Cutive Mono', \ }, \ 'pencil_light':{ 'colorscheme': 'pencil', \ 'background': 'light', \ 'columns': 75, \ 'font-size': 20, \ 'fullscreen': 1, \ 'laststatus': 0, \ 'linespace': 8, \ 'airline-theme': 'light', \ 'typeface': 'Cousine', \ }, \ 'pencil_dark': { 'colorscheme': 'pencil', \ 'background': 'dark', \ 'font-size': 20, \ 'fullscreen': 1, \ 'laststatus': 0, \ 'linespace': 8, \ 'airline-theme': 'badwolf', \ 'typeface': 'Cousine', \ }, \ 'traditional': { 'colorscheme': 'pencil', \ 'background': 'light', \ 'font-size': 20, \ 'laststatus': 0, \ 'linespace': 8, \ 'typeface': 'Linux Libertine Mono O', \ }, \ 'hemi_dark' : { 'colorscheme': 'hemisu', \ 'font-size': 8, \ 'linespace': 0, \ 'typeface': 'Menlo', \ }, \ 'hemi_lite' : { 'colorscheme': 'hemisu', \ 'background': 'light', \ 'columns': 75, \ 'typeface': 'CosmicSansNeueMono', \ }, \ 'matrix' : { 'colorscheme': 'base16-greenscreen', \ 'font-size': 24, \ 'linespace': 9, \ 'typeface': 'Dot Matrix', \ }, \ 'solar_dark' : { 'colorscheme': 'solarized', \ 'diff-color-fix': 1, \ 'sign-column': 1, \ 'sign-column-color-fix': 1, \ 'typeface': 'Source Code Pro Light', \ }, \ 'solar_lite' : { 'colorscheme': 'solarized', \ 'background': 'light', \ 'font-size': 20, \ 'sign-column-color-fix': 1, \ 'typeface': 'Source Code Pro Medium', \ }, \ 'github' : { 'background': 'light' }, \ } "let g:thematic#theme_name = 'desert' " Motions to Ack for things. Works with pretty much everything, including: " w, W, e, E, b, B, t*, f*, i*, a*, and custom text objects " Note: If the text covered by a motion contains a newline it won't work. Ack " searches line-by-line. nnoremap ,a :set opfunc=AckMotiong@ xnoremap ,a :call AckMotion(visualmode()) function! s:CopyMotionForType(type) if a:type ==# 'v' silent execute "normal! `<" . a:type . "`>y" elseif a:type ==# 'char' silent execute "normal! `[v`]y" endif endfunction function! s:AckMotion(type) abort let reg_save = @@ call s:CopyMotionForType(a:type) execute "normal! :Ack! --literal " . shellescape(@@) . "\" let @@ = reg_save endfunction " # CtrlP (navigation) " http://kien.github.com/ctrlp.vim/ nmap ,b :CtrlPBuffer nmap ,m :CtrlPMRU "let g:ctrlp_map = '' let g:ctrlp_map = 'f' let g:ctrlp_working_path_mode = 0 " don't manage let g:ctrlp_by_filename = 1 " only consider filename, not full path let g:ctrlp_match_window_bottom = 0 let g:ctrlp_match_window_reversed = 0 let g:ctrlp_dotfiles = 0 let g:ctrlp_switch_buffer = 0 let g:ctrlp_buffer_func = { 'enter': 'MyCtrlPMappings' } " The Silver Searcher if executable('ag') " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' " ag is fast enough that CtrlP doesn't need to cache let g:ctrlp_use_caching = 0 let g:ackprg = 'ag --smart-case --nogroup --nocolor --column' set grepprg=ag\ --nogroup\ --nocolor endif func! MyCtrlPMappings() nnoremap :call DeleteBuffer() endfunc func! s:DeleteBuffer() let line = getline('.') let bufid = line =~ '\[\d\+\*No Name\]$' ? str2nr(matchstr(line, '\d\+')) \ : fnamemodify(line[2:], ':p') exec "bd" bufid exec "norm \" endfunc " # NERD Tree (directory browser) nmap ,t :set columns=999:NERDTreeToggle nmap ,T :set columns=999:NERDTreeFind let NERDChristmasTree=1 let NERDTreeChDirMode=2 let NERDTreeDirArrows=1 let NERDTreeHighlightCursorline=1 let NERDTreeIgnore=[ '\.pyc$', '\.bak$', '\.zip$', '\.xz$' ] let NERDTreeMapJumpFirstChild = 'gK' let NERDTreeMinimalUI=1 let NERDTreeShowHidden=1 " quit if nerdtree is the last buffer open autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif " Try ]c and [c to jump between hunks let g:signify_sign_change='~' let g:signify_sign_delete='-' let g:signify_sign_overwrite=0 " prevent dumping gutter let g:signify_update_on_focusgained=1 " dumps gutter if overwrite=1 let g:signify_sign_color_inherit_from_linenr=1 let g:airline#extensions#whitespace#show_message = 0 let g:airline#extensions#whitespace#checks = [ ] let g:airline_powerline_fonts = 0 let g:airline_left_sep = '' let g:airline_right_sep = '' let g:airline_linecolumn_prefix = '' let g:airline_fugitive_prefix = '⎇' let g:airline_paste_symbol = 'ρ' let g:airline_section_x = '' let g:airline_section_y = "%{strlen(&ft)?&ft:'none'}" " =============================================================== " "function! ToggleMinimap() " if exists("s:isMini") && s:isMini == 0 " let s:isMini = 1 " else " let s:isMini = 0 " end " " if (s:isMini == 0) " " save current visible lines " let s:firstLine = line("w0") " let s:lastLine = line("w$") " " " make font small " exe "set guifont=" . g:small_font " " highlight lines which were visible " let s:lines = "" " for i in range(s:firstLine, s:lastLine) " let s:lines = s:lines . "\\%" . i . "l" " " if i < s:lastLine " let s:lines = s:lines . "\\|" " endif " endfor " " exe 'match Visible /' . s:lines . '/' " hi Visible guibg=lightblue guifg=black term=bold " nmap 10j " nmap 10k " else " exe "set guifont=" . g:main_font " hi clear Visible " nunmap " nunmap " endif "endfunction " "let g:main_font = "Anonymous\\ Pro:h18" "let g:small_font = "Anonymous\\ Pro:h2" "command! ToggleMinimap call ToggleMinimap() " vim:set ft=vim et sw=2: