set nocompatible filetype off " Vundle setup {{{ set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() Bundle 'gmarik/Vundle.vim' Bundle 'ervandew/supertab' Bundle 'airblade/vim-gitgutter' Bundle 'scrooloose/syntastic' Bundle 'tpope/vim-fugitive' Bundle 'tpope/vim-surround' Bundle 'vim-scripts/multvals.vim' Bundle 'altercation/vim-colors-solarized' Bundle 'vim-scripts/django.vim' "Bundle 'tpope/vim-markdown' Plugin 'godlygeek/tabular' Plugin 'preservim/vim-markdown' Bundle 'amperser/proselint' Bundle 'jgdavey/tslime.vim' Bundle 'christoomey/vim-tmux-navigator' Bundle 'nicholaides/words-to-avoid.vim' Bundle 'reedes/vim-wordy' Bundle 'vim-scripts/vim-auto-save' Bundle 'tmhedberg/SimpylFold' Bundle 'nvie/vim-flake8' "Bundle 'francoiscabrol/ranger.vim' Bundle 'elijahdanko/lf.vim' Bundle 'junegunn/fzf' Bundle 'junegunn/fzf.vim' Bundle 'chengzeyi/fzf-preview.vim' Bundle 'alok/notational-fzf-vim' call vundle#end() filetype plugin indent on "}}} " Basic stuff {{{ set encoding=utf-8 set scrolloff=3 set modelines=0 set guifont=Inconsolata:h16 set tabstop=4 set shiftwidth=4 set softtabstop=4 set expandtab set cursorline set autoindent set hidden set number set undofile set cpoptions+=$ set cmdheight=1 set laststatus=1 set showcmd set showmode set backspace=indent,eol,start let mapleader = "," "save things when we turn our back autocmd BufLeave,FocusLost * silent! wall " save things all the time: let g:auto_save = 1 let g:auto_save_in_insert_mode = 0 "}}} " Abbreviations {{{ " easier markdown links: let @a ='Sr%a()h' let @s ='Sr%a(){: rel=nofollow}17h' " email signature: let @c ='icheers Scott Gilbertson sng@luxagraf.net ' let @w ='i cheers Scott Gilbertson -- ' let @t ='iThank you for your help. ' let @h ="iHello, my name is Scott Gilbertson and and I am a product writer with WIRED's Gear team. I am reaching out because we're working on an article about " let @d ='
' " get rid of line breaks in paragraphs let @p ='g/^./ .,/^$/-1 join' let @v='/a bit|a little|sort of|kind of|rather|quite|very|too|pretty much' :iab tds strftime("%Y-%m-%d %a") " }}} " Convenience mappings {{{ "for rewrapping things when composing email map q gq} augroup mail_filetype autocmd! autocmd VimEnter /tmp/mutt* set formatoptions=aw tw=72 augroup END "uppercase words nnoremap up :%s/\<./\u&/g "Lowercase words nnoremap down :%s/\<./\l&/g "conver to emdash nnoremap - :%s/ -- /—/g nnoremap cd :lcd %:p:h nmap nw :.w! >> $NOTES \| echo "Line written to notes" vmap nw :w! >> $NOTES \| echo "Selection written to notes" " sane spelling options nnoremap sp :set spell! spelllang=en_us spell? set spellfile=~/.vim/dict.add map ]s map z= "quicker way to get to the thesaurus: inoremap ;t nnoremap ;m :%s/ $// "Let's just leave the whole w out of it shall we. noremap h noremap j noremap k noremap l inoremap =strftime("%Y-%m-%d") nmap ,t yiw:call AddTag('"') vmap ,t y:call AddTag('"') function! AddTag(tagname) let tagname = input('Tag name: ', a:tagname, 'tag') let tagfile = expand('%:p') let tagaddress = input('Address: ', '/\<' . a:tagname . '\>/') if (tagname == '' || tagaddress == '') return endif let cmd = '!echo -e "' . tagname . '\t' . tagfile . '\t' . tagaddress . '" >> ' . $HOME . '/.tags.global' execute cmd endfunction " Convert curly quotes to straight. {{{ " Any argument causes substitute to confirm changes. function! ToStraight(line1, line2, args) let flags = 'eg' let range = a:line1 . ',' . a:line2 if empty(a:args) let range = 'silent ' . range else let flags .= 'c' endif let search = @/ exe range . "s/[‘’]/'/" . flags exe range . 's/[“””]/"/' . flags nohl let @/ = search endfunction "}}} " command! -nargs=? -range ToStraight call ToStraight(, , '') nnoremap ,str :%ToStraight " Keep search matches in the middle of the window. nnoremap N nzzzv nnoremap n Nzzzv " Easier to type, and I never use the default behavior. noremap H ^ noremap L $ vnoremap L g_ nnoremap nnoremap inoremap inoremap inoremap inoremap nnoremap j gj nnoremap k gk set clipboard=unnamedplus " Visual mode pressing * or # searches for the current selection " Super useful! From an idea by Michael Naumann vnoremap * :call VisualSelection('f') vnoremap # :call VisualSelection('b') "yank a line, not a line and some more nnoremap Y y$ nnoremap it /\vit's\|its " Fuck you, help key. noremap :checktime inoremap :checktime " zt is okay for putting something at the top of the screen, but when I'm " writing prose I often want to put something at not-quite-the-top of the " screen. zh is "zoom to head level" nnoremap zh mzzt10`z " Easier linewise reselection of what you just pasted. nnoremap V V`] " HTML tag closing inoremap :call InsertCloseTag()a " Select (charwise) the contents of the current line, excluding indentation. " Great for pasting Python lines into REPLs. nnoremap vv ^vg_ " Sudo to write cnoremap w!! w !sudo tee % >/dev/null " Insert Mode Completion {{{ inoremap inoremap inoremap " }}} " }}} " Searching ------------------------------------------------------------------- {{{ nnoremap / /\v vnoremap / /\v set ignorecase set smartcase set gdefault set incsearch set noshowmatch set hlsearch nnoremap :noh " }}} " Tab Completion -------------------------------------------------------------- {{{ set wildmode=list:longest,list:full set wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/* "}}} nnoremap nt :Lf " Backups ----------------------------------------------------------------------{{{ set backup " enable backups set noswapfile " it's 2013, Vim. set undodir=~/.vimtmp/undo// " undo files set backupdir=~/.vimtmp/backup// " backups set directory=~/.vimtmp/swap// " swap files " Make those folders automatically if they don't already exist. if !isdirectory(expand(&undodir)) call mkdir(expand(&undodir), "p") endif if !isdirectory(expand(&backupdir)) call mkdir(expand(&backupdir), "p") endif if !isdirectory(expand(&directory)) call mkdir(expand(&directory), "p") endif " Make Vim able to edit crontab files again. set backupskip=/tmp/*,/private/tmp/*" " }}} "Thesaurus set thesaurus+=/home/lxf/.mthesaur.txt "}}} " Filetype stuff {{{ augroup ft_vim au! au FileType vim setlocal foldmethod=marker au FileType help setlocal textwidth=78 augroup END " If the current buffer has never been saved, it will have no name, " call the file browser to save it, otherwise just save it. nnoremap :if expand("%") == ""browse confirm welseconfirm wendif autocmd BufRead,BufNewFile *.css,*.scss,*.less setlocal foldmethod=marker foldmarker={,} " turn on sentences level undo for prose: function s:undosentences () inoremap . .u inoremap ! !u inoremap ? ?u inoremap : :u setl wrap linebreak textwidth=0 wrapmargin=0 synmaxcol=999 filetype=markdown spell endfunction " txt, text, md and markdown are markdown files au BufEnter,BufRead,BufNewFile *.{text,txt,md,markdown} call s:undosentences() " syntastic and proselint let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 0 let g:syntastic_markdown_checkers = ['proselint'] " wrap python and other files: function s:mypythonsettings() highlight BadWhitespace ctermbg=red guibg=red "set foldmethod=indent "set textwidth=79 endfunction au BufRead,BufNewFile *.py,*.pyw,*.c,*.h call s:mypythonsettings() "}}} " Colors {{{ syntax on set background=dark let g:solarized_termtrans = 1 colorscheme solarized set t_Co=256 " force vim to use 256 colors let g:solarized_termcolors=256 "}}}" " Folding {{{ set foldlevelstart=0 " Space to toggle folds. nnoremap za vnoremap za " Make zO recursively open whatever fold we're in, even if it's partially open. nnoremap zO zczO " "Focus" the current line. Basically: " " 1. Close all folds. " 2. Open just the folds containing the current line. " 3. Move the line to a little bit (15 lines) above the center of the screen. " 4. Pulse the cursor line. My eyes are bad. " " This mapping wipes out the z mark, which I never use. " " I use :sus for the rare times I want to actually background Vim. nnoremap mzzMzvzz8`z:Pulse function! MyFoldText() " {{{ let line = getline(v:foldstart) let nucolwidth = &fdc + &number * &numberwidth let windowwidth = winwidth(0) - nucolwidth - 3 let foldedlinecount = v:foldend - v:foldstart " expand tabs into spaces let onetab = strpart(' ', 0, &tabstop) let line = substitute(line, '\t', onetab, 'g') let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount)) let fillcharcount = windowwidth - len(line) - len(foldedlinecount) return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' ' endfunction " }}} set foldtext=MyFoldText() augroup javascript_folding au! au FileType javascript setlocal foldmethod=syntax augroup END " Disable commands for creating and deleting folds. "noremap zf "noremap zF "noremap zd "noremap zD noremap zE " }}} " Plugins {{{ " SimpylFold Python folding plugin {{{ let g:SimpylFold_docstring_preview = 0 "}}} " make YCM compatible with UltiSnips (using supertab) let g:ycm_key_list_select_completion = ['', ''] let g:ycm_key_list_previous_completion = ['', ''] let g:SuperTabDefaultCompletionType = '' nnoremap :NV let g:markdown_folding = 1 let g:markdown_fold_style = 'nested' let g:vim_markdown_folding_style_pythonic = 1 nmap i :%s/ //g nmap # :%s/### /###/g imap jj vmap r :'<,'>:w !espeak &> /dev/null "FZF {{{ let g:fzf_preview_window='right:60%' let g:fzf_history_dir = '~/.local/share/fzf-history' set grepprg=rg\ --vimgrep\ --smart-case\ --hidden\ --follow nnoremap r :History nnoremap l :Rg nnoremap f :Files nnoremap g :BLines nnoremap n :FZF ~/notes/ "}}} " FZF Notational Velocity plugin {{{ let g:nv_search_paths = ['~/notes', '~/writing/luxagraf/', '~/documents/bookmarks/'] "}}} "