1. " no vi-compatible
  2. set nocompatible
  3.  
  4. " Setting up Vundle - the vim plugin bundler
  5. let iCanHazVundle=1
  6. let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
  7. if !filereadable(vundle_readme)
  8.     echo "Installing Vundle..."
  9.     echo ""
  10.     silent !mkdir -p ~/.vim/bundle
  11.     silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
  12.     let iCanHazVundle=0
  13. endif
  14.  
  15. " required for vundle
  16. filetype off
  17.  
  18. set rtp+=~/.vim/bundle/vundle/
  19. call vundle#rc()
  20.  
  21. " let Vundle manage Vundle
  22. " required!
  23. Bundle 'gmarik/vundle'
  24.  
  25. Bundle 'vim-smooth-scroll'
  26. Bundle 'vim-multiple-cursors'
  27. " Needed for powerline
  28. Bundle 'Tagbar'
  29. Bundle 'fugitive.vim'
  30. Bundle 'Syntastic'
  31. Bundle 'SuperTab'
  32. Bundle 'kien/ctrlp.vim'
  33. Bundle 'fisadev/vim-ctrlp-cmdpalette'
  34. Bundle 'mattn/emmet-vim'
  35. Bundle 'motemen/git-vim'
  36. Bundle 'Lokaltog/vim-powerline'
  37. Bundle 'rosenfeld/conque-term'
  38. Bundle 'michaeljsmith/vim-indent-object'
  39. Bundle 'airblade/vim-gitgutter'
  40. Bundle 'IndexedSearch'
  41.  
  42. " Installing plugins the first time
  43. if iCanHazVundle == 0
  44.     echo "Installing Bundles, please ignore key map error messages"
  45.     echo ""
  46.     :BundleInstall
  47. endif
  48.  
  49. " allow plugins by file type
  50. filetype plugin on
  51. filetype indent on
  52. syntax enable
  53.  
  54. set t_Co=256
  55. colorscheme xoria256
  56. set showmatch
  57. set ignorecase
  58. set cindent
  59. set ai
  60. set cul
  61. set guioptions-=mlrbT
  62.  
  63. " tabs and spaces handling
  64. set expandtab
  65. set tabstop=4
  66. set softtabstop=4
  67. set shiftwidth=4
  68.  
  69. " tablength exceptions
  70. autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2
  71. autocmd FileType htmldjango setlocal shiftwidth=2 tabstop=2 softtabstop=2
  72. autocmd FileType javascript setlocal shiftwidth=2 tabstop=2 softtabstop=2
  73.  
  74. " always show status bar
  75. set ls=2
  76.  
  77. " incremental search
  78. set incsearch
  79.  
  80. " highlighted search results
  81. set hlsearch
  82.  
  83. " line numbers
  84. set nu
  85.  
  86. " save as sudo
  87. ca w!! w !sudo tee "%"
  88.  
  89. " CtrlP (new fuzzy finder)
  90. let g:ctrlp_map = ',e'
  91. nmap ,g :CtrlPBufTag<CR>
  92. nmap ,G :CtrlPBufTagAll<CR>
  93. nmap ,f :CtrlPLine<CR>
  94. nmap ,m :CtrlPMRUFiles<CR>
  95. nmap ,c :CtrlPCmdPalette<CR>
  96. " to be able to call CtrlP with default search text
  97. function! CtrlPWithSearchText(search_text, ctrlp_command_end)
  98.     execute ':CtrlP' . a:ctrlp_command_end
  99.     call feedkeys(a:search_text)
  100. endfunction
  101. " CtrlP with default text
  102. nmap ,wg :call CtrlPWithSearchText(expand('<cword>'), 'BufTag')<CR>
  103. nmap ,wG :call CtrlPWithSearchText(expand('<cword>'), 'BufTagAll')<CR>
  104. nmap ,wf :call CtrlPWithSearchText(expand('<cword>'), 'Line')<CR>
  105. nmap ,we :call CtrlPWithSearchText(expand('<cword>'), '')<CR>
  106. nmap ,pe :call CtrlPWithSearchText(expand('<cfile>'), '')<CR>
  107. nmap ,wm :call CtrlPWithSearchText(expand('<cword>'), 'MRUFiles')<CR>
  108. nmap ,wc :call CtrlPWithSearchText(expand('<cword>'), 'CmdPalette')<CR>
  109. " Don't change working directory
  110. let g:ctrlp_working_path_mode = 0
  111. " Ignore files on fuzzy finder
  112. let g:ctrlp_custom_ignore = {
  113.   \ 'dir':  '\v[\/](\.git|\.hg|\.svn)$',
  114.   \ 'file': '\.pyc$\|\.pyo$',
  115.   \ }
  116.  
  117. " simple recursive grep
  118. command! -nargs=1 RecurGrep lvimgrep /<args>/gj ./**/*.* | lopen | set nowrap
  119. command! -nargs=1 RecurGrepFast silent exec 'lgrep! <q-args> ./**/*.*' | lopen
  120. nmap ,R :RecurGrep
  121. nmap ,r :RecurGrepFast
  122. nmap ,wR :RecurGrep <cword><CR>
  123. nmap ,wr :RecurGrepFast <cword><CR>
  124.  
  125. " smooth scroll https://github.com/terryma/vim-smooth-scroll
  126. noremap <silent> <C-a> :call smooth_scroll#up(&scroll, 10, 2)<CR>
  127. noremap <silent> <C-x> :call smooth_scroll#down(&scroll, 10, 2)<CR>
  128.  
  129. " multiple cursors https://github.com/terryma/vim-multiple-cursors
  130. let g:multi_cursor_use_default_mapping=0
  131. let g:multi_cursor_next_key='<C-d>'
  132. let g:multi_cursor_prev_key='<C-p>'
  133. let g:multi_cursor_skip_key='<C-x>'
  134. let g:multi_cursor_quit_key='<Esc>'
  135.  
  136. " use 256 colors when possible
  137. if &term =~? 'mlterm\|xterm\|xterm-256\|screen-256'
  138.     let &t_Co = 256
  139. endif
  140.  
  141. " when scrolling, keep cursor 3 lines away from screen border
  142. set scrolloff=3
  143.  
  144. " autocompletion of files and commands behaves like shell
  145. " (complete only the common part, list the options that match)
  146. set wildmode=list:longest
  147.  
  148. " to use fancy symbols for powerline, uncomment the following line and use a
  149. " patched font (more info on the README.rst)
  150. let g:Powerline_symbols = 'fancy'
  151.  
  152. set clipboard=unnamedplus
  153. set guioptions-=l
  154. set guioptions-=L
  155. set guioptions-=m
  156. set guioptions-=r
  157. set guioptions-=R
  158. set guioptions-=T
  159. if has("gui_running")
  160.   if has("gui_gtk2")
  161.     set guifont=Ubuntu\ Mono\ for\ Powerline\ 9
  162.   endif
  163. endif
  164. imap jk <Esc>