.vimrc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. set nocompatible
  2. " include Vundle
  3. set rtp+=~/.vim/bundle/Vundle.vim
  4. call vundle#begin()
  5. Plugin 'scrooloose/nerdtree'
  6. Plugin 'scrooloose/syntastic'
  7. Plugin 'scrooloose/nerdcommenter'
  8. Plugin 'Xuyuanp/nerdtree-git-plugin'
  9. Plugin 'tpope/vim-fugitive'
  10. Plugin 'airblade/vim-gitgutter'
  11. Plugin 'tpope/vim-surround'
  12. Plugin 'jiangmiao/auto-pairs'
  13. call vundle#end()
  14. filetype plugin indent on
  15. " END Vundle
  16. map <C-n> :NERDTreeToggle<CR>
  17. set number
  18. set ruler
  19. syntax on
  20. " Set encoding
  21. set encoding=utf-8
  22. " Whitespace stuff
  23. set nowrap
  24. set tabstop=2
  25. set shiftwidth=2
  26. set softtabstop=2
  27. set expandtab
  28. set list listchars=tab:\ \ ,trail:ยท
  29. " Searching
  30. set hlsearch
  31. set incsearch
  32. set ignorecase
  33. set smartcase
  34. " Tab completion
  35. set wildmode=list:longest,list:full
  36. set wildignore+=*.o,*.obj,.git,*.rbc,*.class,.svn,vendor/gems/*
  37. " Status bar
  38. set laststatus=2
  39. " Without setting this, ZoomWin restores windows in a way that causes
  40. " equalalways behavior to be triggered the next time CommandT is used.
  41. " This is likely a bludgeon to solve some other issue, but it works
  42. set noequalalways
  43. " NERDTree configuration
  44. let NERDTreeIgnore=['\.pyc$', '\.rbc$', '\~$']
  45. map <Leader>n :NERDTreeToggle<CR>
  46. " Command-T configuration
  47. let g:CommandTMaxHeight=20
  48. " ZoomWin configuration
  49. map <Leader><Leader> :ZoomWin<CR>
  50. " CTags
  51. map <Leader>rt :!ctags --extra=+f -R *<CR><CR>
  52. map <C-\> :tnext<CR>
  53. " Remember last location in file
  54. if has("autocmd")
  55. au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
  56. \| exe "normal g'\"" | endif
  57. endif
  58. function s:setupWrapping()
  59. set wrap
  60. set wrapmargin=2
  61. set textwidth=72
  62. endfunction
  63. function s:setupMarkup()
  64. call s:setupWrapping()
  65. map <buffer> <Leader>p :Hammer<CR>
  66. endfunction
  67. " make uses real tabs
  68. au FileType make set noexpandtab
  69. " Thorfile, Rakefile, Vagrantfile and Gemfile are Ruby
  70. au BufRead,BufNewFile {Gemfile,Rakefile,Vagrantfile,Thorfile,config.ru} set ft=ruby
  71. " md, markdown, and mk are markdown and define buffer-local preview
  72. au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn} call s:setupMarkup()
  73. " add json syntax highlighting
  74. au BufNewFile,BufRead *.json set ft=javascript
  75. au BufRead,BufNewFile *.txt call s:setupWrapping()
  76. " make Python follow PEP8 ( http://www.python.org/dev/peps/pep-0008/ )
  77. au FileType python set softtabstop=4 tabstop=4 shiftwidth=4 textwidth=79
  78. " allow backspacing over everything in insert mode
  79. set backspace=indent,eol,start
  80. " load the plugin and indent settings for the detected filetype
  81. filetype plugin indent on
  82. " Opens an edit command with the path of the currently edited file filled in
  83. " Normal mode: <Leader>e
  84. map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
  85. " Opens a tab edit command with the path of the currently edited file filled in
  86. " Normal mode: <Leader>t
  87. map <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
  88. " Inserts the path of the currently edited file into a command
  89. " Command mode: Ctrl+P
  90. cmap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
  91. " Unimpaired configuration
  92. " Bubble single lines
  93. nmap <C-Up> [e
  94. nmap <C-Down> ]e
  95. " Bubble multiple lines
  96. vmap <C-Up> [egv
  97. vmap <C-Down> ]egv
  98. " Enable syntastic syntax checking
  99. let g:syntastic_enable_signs=1
  100. let g:syntastic_quiet_warnings=1
  101. " gist-vim defaults
  102. if has("mac")
  103. let g:gist_clip_command = 'pbcopy'
  104. elseif has("unix")
  105. let g:gist_clip_command = 'xclip -selection clipboard'
  106. endif
  107. let g:gist_detect_filetype = 1
  108. let g:gist_open_browser_after_post = 1
  109. " Use modeline overrides
  110. set modeline
  111. set modelines=10
  112. " Default color scheme
  113. color sunburst
  114. " Directories for swp files
  115. set backupdir=~/.vim/backup
  116. set directory=~/.vim/backup
  117. " Turn off jslint errors by default
  118. let g:JSLintHighlightErrorLine = 0
  119. " MacVIM shift+arrow-keys behavior (required in .vimrc)
  120. let macvim_hig_shift_movement = 1
  121. " % to bounce from do to end etc.
  122. runtime! macros/matchit.vim
  123. " Show (partial) command in the status line
  124. set showcmd
  125. " Include user's local vim config
  126. if filereadable(expand("~/.vimrc.local"))
  127. source ~/.vimrc.local
  128. endif