public
Last active

.vimrc.local (used on top of spf13 .vimrc)

  • Download Gist
.vimrc
VimL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
" Modeline and Notes {{{
" vim: set foldmarker={{{,}}} foldlevel=0 foldmethod=marker
"
" This is the personal .vimrc.local file of Will Mayner.
"
" It is meant to be used on top of Steve Francia's spf13-vim
" distribution, at https://github.com/spf13/spf13-vim.
"
" }}}
 
" Environment {{{
 
" use aliases running shell commands within vim
set shell=/bin/bash\ --rcfile\ ~/.bash_profile\ -i
 
"spf13 bundles
let g:spf13_bundle_groups=['general', 'neocomplcache', 'programming', 'php', 'javascript', 'html', 'misc',]
 
" }}}
 
" General {{{
 
" switch to existing tab if buffer is open, otherwise create new one
set switchbuf=usetab,newtab
 
set wrapscan " searches wrap around the end of the file
 
set ai " automatically set the indent of a new line (local to buffer)
 
" for .tex files, autowrite if switching buffer or quitting
autocmd FileType tex set autowrite
 
" }}}
 
" Vim UI {{{
 
" set filetype to 'tex' for .tex files
autocmd BufNewFile,BufRead *.tex set filetype=tex
 
" Code folding {{{
 
" " helper functions for foldexpr {{{
" " for an explanation of these helper functions, see
" " http://learnvimscriptthehardway.stevelosh.com/chapters/49.html#expr-folding
 
" function! NextNonBlankLine(lnum)
" let numlines = line('$')
" let current = a:lnum + 1
 
" while current <= numlines
" if getline(current) =~? '\v\S'
" return current
" endif
 
" let current += 1
" endwhile
 
" return -2
" endfunction
 
" function! IndentLevel(lnum)
" return indent(a:lnum) / &shiftwidth
" endfunction
 
" " }}}
 
" default code folding, excludes help files {{{
 
if !(&ft=='help')
setlocal foldlevel=0 " file opens with everything folded
setlocal foldmethod=marker " fold using markers
setlocal foldmarker={{{,}}} " fold things in triple braces
endif
 
" " attempt at using foldexpr for default folding {{{
 
" if !(&ft=='tex' || &ft=='txt' || &ft=='help')
" setlocal foldlevel=0 " file opens with everything folded
" setlocal foldmethod=expr " fold using markers
" setlocal foldexpr=GetDefaultFold(v:lnum) " fold things in braces
" endif
 
" function! GetDefaultFold(lnum)
" if getline(a:lnum) =~? '\v^\s*$'
" return '-1'
" endif
" if getline(a:lnum) =~? '\v.*\{\{\{'
" return 'a1'
" endif
" if getline(a:lnum) =~? '\v.*}\}\}'
" return 's1'
" endif
 
" let this_indent = IndentLevel(a:lnum)
" let next_indent = IndentLevel(NextNonBlankLine(a:lnum))
 
" if next_indent == this_indent
" return this_indent
" elseif next_indent < this_indent
" return this_indent
" elseif next_indent > this_indent
" return '>' . next_indent
" endif
" endfunction
 
" " }}}
 
" }}}
 
" TeX {{{
 
if &ft=='tex'
setlocal foldlevel=0 " file opens with everything folded
setlocal foldmethod=marker " fold using markers
setlocal foldmarker=%{{{,%}}} " fold things in commented triple braces
endif
 
" attempt at using foldexpr {{{
 
" if &ft=='tex'
 
" setlocal foldlevel=0 " file opens with everything folded
" setlocal foldmethod=expr " fold using expressions
" setlocal foldexpr=GetTeXFold(v:lnum) " use function below to determine the fold expression
 
" " fold anything in in %{ %} and inside environments
" function! GetTeXFold(lnum)
" if getline(a:lnum) =~? '\v^\s*$' " if we're on a blank line...
" return '-1' " ...the fold level is undefined
" endif
" if getline(a:lnum) =~? '\v^\s*\\begin\{.*\}' " if the first thing on the line is \begin{<env>}...
" return 'a1' " ...'add 1' to fold level
" endif
" if getline(a:lnum) =~? '\v^\s*\\end\{.*\}' " if the last thing on the line is \end{<env>}...
" return 's1' " ...'add 1' to fold level
" endif
" if getline(a:lnum) =~? '\v^.*\%\{$' " if the last thing on the line is %{
" return 'a1' " ...'add 1' to fold level
" endif
" if getline(a:lnum) =~? '\v^.*\%\}$' " if the last thing on the line is %}
" return 's1' " ...'subtract 1' to fold level
" endif
" return '=' " otherwise the fold level is inherited from previous line
" endfunction
 
" endif
 
" }}}
 
" }}}
 
" CoffeeScript {{{
 
" code folding (delete nofoldenable to enable folding by default)
autocmd BufNewFile,BufReadPost *.coffee setl foldmethod=indent "nofoldenable
 
" always use 2-space tabs
autocmd BufNewFile,BufReadPost *.coffee setl shiftwidth=2 expandtab
 
" }}}
 
" spf13 .vimrc {{{
 
" spf13 uses single braces for folding, so make a special case for that
autocmd BufNewFile,BufReadPost *.vimrc setl foldmethod=marker foldmarker={,} foldlevel=0
 
" }}}
 
" " }}}
 
set vb " stop vim from beeping all the damn time
 
set cursorcolumn " highlight the column the cursor is on
 
set showmatch " show matching parens
 
" Solarized {{{
 
let g:solarized_termcolors=16 " use proper solarized palette
""set t_Co=R56
let g:solarized_contrast="normal"
let g:solarized_visibility="normal"
color solarized
 
" }}}
 
" }}}
 
" GUI Vim {{{
 
set guifont=Inconsolata-dz:h16 " use Inconsolata-dz font
 
" }}}
 
" Formatting {{{
 
set shiftwidth=2 " use indents of 2 spaces
set tabstop=2 " an indentation every 2 columns
set softtabstop=2 " let backspace delete indent
 
" }}}
 
" Key (re)Mappings {{{
 
unmap <Esc>[H
unmap <Esc>[F
 
" insert default fold markers
nnoremap ,,,,,,, O{{{<Esc>
nnoremap ,,,,,,,, o}}}<Esc>
nmap [f ,,,,,,,\\\
nmap ]f ,,,,,,,,\\\
 
" swap native [f mapping with the above
nnoremap <Leader>F [f
 
" if editing TeX, automatically write and compile when pressing escape in normal/insert
autocmd FileType tex nnoremap <silent><buffer> <Esc> <Esc>:w<CR>
autocmd FileType tex inoremap <silent><buffer> <Esc> <Esc>:w<CR>
autocmd FileType tex nnoremap <silent><buffer> \ll :w<CR>:!latexmk -pdf -f<CR>:<BS>
autocmd FileType tex nnoremap <silent><buffer> \lv :w<CR>:!latexmk -pdf -pv -f<CR>:<BS>
 
" <Leader>vs splits in 2 and sets scrollbind
nnoremap <silent> <Leader>vs :<C-u>let @z=&so<CR>:set so=0 noscb<CR>:bo vs<CR>Ljzt:setl scb<CR><C-w>p:setl scb<CR>:let &so=@z<CR>
 
" copy word to clipboard
nnoremap ,d "*yiw
 
" clear search highlighting with enter key
nnoremap <silent> <CR> :noh<CR>
 
" clear search buffer
nnoremap \cc :let @/ =""<CR>:<backspace>
 
" always do very magic search
" (special characters don't need to be escaped with a '\')
nnoremap / /\v
cmap s/ s/\v
 
" loads current directory into MAMP's local php environment
" IMPORTANT: this destroys the existing one!
nnoremap ,p :!rm\ -r\ /Applications/MAMP/htdocs/*\ \|\|\ cp\ -r\ ./* /Applications/MAMP/htdocs<CR>
 
" window navigation and resizing {{{
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
" horizontal shrink
nnoremap <silent> ,= :exe "resize " . (winheight(0) * 3/2)<CR>
" horizontal expand
nnoremap <silent> ,- :exe "resize " . (winheight(0) * 2/3)<CR>
" vertical shrink
nnoremap <silent> \= :exe "vertical resize" . (winwidth(0) * 3/2)<CR>
" vertical expand
nnoremap <silent> \- :exe "vertical resize" . (winwidth(0) * 2/3)<CR>
" }}}
 
" move line down and match indentation in all modes
" NOTE: those strange symbols are CLI Vim for <M-j> and <M-k>, respectively.
" to see them, enter insert mode, then press <C-v>, then type <M-k>
noremap ∆ :m .+1<CR>==
" move line up and match indentation in all modes
noremap ˚ :m .-2<CR>==
 
" help help navigation
autocmd FileType help nnoremap <buffer> <CR> <C-]>
autocmd FileType help nnoremap <buffer> <BS> <C-O>
autocmd FileType help nnoremap <buffer> o /'\l\{2,\}'<CR>
autocmd FileType help nnoremap <buffer> O ?'\l\{2,\}'<CR>
autocmd FileType help nnoremap <buffer> s /\|\zs\S\+\ze\|<CR>
autocmd FileType help nnoremap <buffer> S ?\|\zs\S\+\ze\|<CR>
 
" edit this file
nnoremap \v :e ~/.vimrc.local<CR>
 
" reload this file
nnoremap \s :source ~/.vimrc.local<CR>
 
" edit .vimrc
if !exists("VRC_command_loaded")
let VRC_command_loaded=1
command VRC e ~/.vimrc
endif
 
" reload this .vimrc
if !exists("SVRC_command_loaded")
let SVRC_command_loaded=1
command SVRC source ~/.vimrc
endif
 
" edit local bundles
if !exists("EB_command_loaded")
let EB_command_loaded=1
command EB e ~/.vimrc.bundles.local
endif
 
" swap : and ;
nnoremap ; :
nnoremap : ;
vnoremap ; :
vnoremap : ;
 
" space will toggle folds
nnoremap <space> za
 
" search mappings: these will make it so that going to the next one in a
" search will center on the line it's found in.
noremap N Nzz
noremap n nzz
 
" }}}
 
" Plugins {{{
 
" Tabularize {{{
 
" tabularize for LaTeX tables
nnoremap <Leader>a& :Tabularize /&
 
" tabularize for LaTeX comments
nnoremap <Leader>a% :Tabularize /%
 
" }}}
 
" MiniBufExplorer {{{
 
let g:miniBufExplMapWindowNavVim=1
let g:miniBufExplMapWindowNavArrows=1
let g:miniBufExplMapCTabSwitchBufs=1
let g:miniBufExplModSelTarget=1
 
" }}}
 
" indent_guides {{{
 
" disable by default (press <Leader>ig to activate)
let g:indent_guides_enable_on_vim_startup=0
 
" }}}
 
" ctrlp {{{
 
" use ctrlp but keep <C-t> mapping
let g:ctrlp_map='<C-t>'
 
" }}}
 
" Gundo {{{
 
" Gundo shortcut
nnoremap ,u :GundoToggle<CR>
 
" }}}
 
" vim-surround {{{
 
" type cs"- to change "text" to ``text'' (for LaTeX ligatures)
autocmd FileType tex let b:surround_45="``\r''""'"
" }}}
 
" LaTeX-Suite {{{
 
" override <Leader>lv
nnoremap <Leader>lv :silent !open expand("%:r") . '.pdf'<CR>:echo worked!<CR>
 
" IMPORTANT- grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name."
set grepprg=grep\ -nH\ $*
 
" compile to pdf and use preview
let g:Tex_DefaultTargetFormat='pdf'
 
" pdf compile and view settings
" let g:Tex_ViewRule_pdf='Skim'
let g:Tex_CompileRule_pdf='latexmk -pdf'
 
" dvi compile and view settings
let g:Tex_ViewRule_dvi="Skiim"
let g:Tex_CompileRule_dvi='latex -src -specials -interaction=nonstopmode $*'
 
" ignore all warnings below level 4
let g:TCLevel=4
 
" go to first error after pressing \ll
let g:Tex_GotoError=1
 
" one last thing for latex
let g:tex_flavor='latex'
 
" }}}
 
" " LaTeX-Box {{{
 
" " set latexmk options to 'preview continuously' and -pdfps (from http://stackoverflow.com/questions/3723493/latex-and-vim-usage)
" let g:LatexBox_latexmk_options='-pvc'
 
" " view output with Skim
" let g:LatexBox_viewer='open -a Skim'
 
" " automatically jump to position in pdf
" let g:LatexBox_autojump=1
 
" " use SyncTex with Skim viewer
" noremap <silent> <Leader>ls :silent !/Applications/Skim.app/Contents/SharedSupport/displayline\ <C-R>=line('.')<CR> "<C-R>=LatexBox_GetOutputFile()<CR>" "%:p" <CR>
 
" " View output
" noremap <Leader>lv :LatexView<CR>
 
" " Compile with latexmk in background.
" noremap <Leader>ll :Latexmk<CR>
 
" " Force compilation with latexmk in background.
" noremap <Leader>lL :LatexmkForce<CR>
 
" " Clean temporary output from LaTeX.
" noremap <Leader>lc :LatexmkClean<CR>
 
" " Clean all output from LaTeX.
" noremap <Leader>lC :LatexmkCleanAll<CR>
 
" " Stop latexmk if it is running.
" noremap <Leader>lk :LatexmkStop<CR>
 
" " Show the running status of latexmk for the current buffer.
" noremap <Leader>lg :LatexmkStatus<CR>
 
" " Show the running status of latexmk for all buffers with process group ID's.
" noremap <LocalLeader>lG :LatexmkStatusDetailed<CR>
 
" " Load the log file for the current document and jump to the first error.
" noremap <Leader>le :LatexErrors<CR>
 
" " }}}
 
" vim-unimpaired {{{
 
" remap some mappings that don't seem to work for some reason
nnoremap [a :previous<CR>
nnoremap ]a :next<CR>
nnoremap [A :first<CR>
nnoremap ]A :last<CR>
nnoremap [b :bprevious<CR>
nnoremap ]b :bnext<CR>
nnoremap [B :bfirst<CR>
nnoremap ]B :blast<CR>
nnoremap [l :lprevious<CR>
nnoremap ]l :lnext<CR>
nnoremap [L :lfirst<CR>
nnoremap ]L :llast<CR>
nnoremap [q :cprevious<CR>
nnoremap ]q :cnext<CR>
nnoremap [Q :cfirst<CR>
nnoremap ]Q :clast<CR>
nnoremap [t :tprevious<CR>
nnoremap ]t :tnext<CR>
nnoremap [T :tfirst<CR>
nnoremap ]T :tlast<CR>
 
" }}}
 
" }}}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.