.vimrc 3.5 KB

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