.vimrc 3.7 KB

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