Advertisement
Guest User

.vimrc

a guest
Jul 1st, 2013
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 11.54 KB | None | 0 0
  1. filetype off
  2.  
  3. set rtp+=~/.vim/vundle.git/
  4. call vundle#rc()
  5.  
  6. set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim
  7.  
  8. "set statusline+=%#warningmsg#
  9. "set statusline+=%{SyntasticStatuslineFlag()}
  10. "set statusline+=%*
  11. let g:syntastic_enable_signs=1
  12. let g:syntastic_auto_loc_list=1
  13.  
  14. let g:ctrlp_working_path_mode = 'ra'
  15. " Bundles
  16. "
  17. " original repos on github
  18.  
  19. "Bundle 'vim-scripts/taglist.vim'
  20. Bundle 'majutsushi/tagbar'
  21.  
  22. "Bundle 'joonty/vim-phpqa.git'
  23. "Bundle 'joonty/vim-phpunitqf'
  24. Bundle 'joonty/vdebug'
  25. " Php
  26. Bundle 'sumpygump/php-documentor-vim'
  27. Bundle 'sophacles/vim-processing'
  28. Bundle 'nelstrom/vim-visual-star-search'
  29. Bundle 'Lokaltog/powerline'
  30. Bundle 'spolu/dwm.vim'
  31. Bundle 'tpope/vim-unimpaired'
  32. Bundle 'airblade/vim-gitgutter'
  33. Bundle 'kien/ctrlp.vim'
  34. Bundle 'wikitopian/hardmode'
  35. Bundle 'tpope/vim-fugitive'
  36. Bundle 'sbl/scvim'
  37. Bundle 'vim-scripts/bufexplorer'
  38. Bundle 'aaronbieber/quicktask'
  39. Bundle 'vim-scripts/The-NERD-Commenter'
  40. Bundle 'tpope/vim-fugitive'
  41. Bundle 'tpope/vim-surround'
  42. Bundle 'vim-scripts/HTML-AutoCloseTag'
  43. Bundle 'scrooloose/nerdtree'
  44. "Bundle 'scrooloose/syntastic'
  45. Bundle 'vim-scripts/css_color.vim'
  46. " Color schemes
  47. Bundle 'tomasr/molokai'
  48. Bundle 'altercation/vim-colors-solarized'
  49. Bundle 'vim-scripts/OOP-javascript-indentation'
  50.  
  51.  
  52. let g:gitgutter_enabled = 0
  53. set nocompatible "Don't be compatible with vi
  54.  
  55. " Enable filetype plugin
  56. filetype indent on
  57. filetype plugin on
  58.  
  59.  
  60. " Set to auto read when a file is changed from the outside
  61. set autoread
  62.  
  63. set t_Co=16
  64. set background=dark                    
  65. set number "Show line numbering
  66. set numberwidth=1 "Use 1 col + 1 space for numbers
  67.  
  68. " With a map leader it's possible to do extra key combinations
  69. let mapleader = ","
  70. let g:mapleader = ","
  71.  
  72. " Toggle NERDTree
  73. map <leader>n :NERDTreeToggle<CR>
  74.  
  75. set backupdir=~/.vim/backup    " where to put backup files
  76. set directory=~/.vim/temp    " where to put swap files
  77.  
  78. " Fast saving
  79. nmap <leader>w :w!<cr>
  80.  
  81. " Fast editing of the .vimrc
  82. map <leader>e :e $MYVIMRC<cr>
  83.  
  84. " When .vimrc is edited, reload it
  85. augroup MyAutoCmd
  86.     autocmd!
  87. augroup END
  88.  
  89. autocmd MyAutoCmd BufWritePost $MYVIMRC nested source $MYVIMRC
  90. "au! BufWritePost .vimrc nested source %
  91. set title
  92.  
  93. " Remap esc key
  94. inoremap jk <esc>
  95.  
  96. " work more logically with wrapped lines
  97. noremap j gj
  98. noremap k gk
  99.  
  100. set smartcase " search case sensitive if caps on
  101. set showcmd " Display what command is waiting for an operator
  102.  
  103. autocmd BufNewFile,BufRead /*apache* setfiletype apache
  104. autocmd BufNewFile,BufRead /*lighttpd*.conf setfiletype lighty
  105. autocmd BufNewFile,BufRead {.,_}vimrc set foldmethod=marker
  106.  
  107. " PhpDocumentor
  108. au BufRead,BufNewFile *.php inoremap <buffer> <leader>p :call PhpDoc()<CR>
  109. au BufRead,BufNewFile *.php nnoremap <buffer> <leader>p :call PhpDoc()<CR>
  110. au BufRead,BufNewFile *.php vnoremap <buffer> <leader>p :call PhpDocRange()<CR>
  111.  
  112.  
  113. " Nicer highlighting of completion popup
  114. highlight Pmenu guibg=brown gui=bold
  115.  
  116.  
  117. set scrolloff=7 "Set 7 lines to the cursors when moving vertical
  118. set wildmenu "Autocomplete features in the status bar
  119. set ruler "Always show current position
  120. set cmdheight=2 "The commandbar height
  121. set hidden "Change buffer without saving
  122.  
  123. " Backspae config
  124. set backspace=eol,start,indent
  125. set whichwrap+=<,>,h,l
  126.  
  127. set ignorecase "Search is case insensitive
  128. set hlsearch "Highlight matches to the search
  129. set incsearch "Show best match so far
  130. set magic "Set magic on for regular expressions
  131. set showmatch "Show matching bracets when text indicator is over them
  132. set mat=2 "How many tenths of a second to blink
  133.  
  134. " No sound on errors
  135. set noerrorbells
  136. set novisualbell
  137. set t_vb=
  138.  
  139. " Colors and fonts {{{1
  140. set term=screen-256color
  141. syntax enable "Enable syntax hl
  142. syntax on "Enable syntax hl
  143. "colorscheme molokai
  144. "let g:solarized_termcolors=256
  145. colorscheme solarized
  146. set guifont=Envy\ Code\ R\ for\ Powerline
  147. set encoding=utf-8
  148. filetype plugin on
  149. "set guifont=Inconsolata\ for\ Powerline\
  150. let g:Powerline_symbols="fancy"
  151.  
  152.  
  153. " Text, tab and indent related {{{1
  154.  
  155. set expandtab "Transform tabs into spaces
  156. set shiftwidth=4 "sw 4 spaces (used on auto indent)
  157. set shiftwidth=4 "sw 4 spaces (used on auto indent)
  158. set tabstop=4 "4 spaces as a tab for bs/del
  159. set smarttab
  160.  
  161. set wrap linebreak tw=80 wm=0 "Wrap lines
  162. set ai "Auto indent
  163. set si "Smart indent
  164. " }}}1
  165. " Moving around, tabs and buffers {{{1
  166.  
  167. " Move to previous and next buffer
  168. :nmap <C-n> :bnext<CR>
  169. :nmap <C-p> :bprev<CR>
  170.  
  171. " Map space to / (search) and c-space to ? (backwards search)
  172. map <space> /
  173. map <c-space> ?
  174. map <silent> <leader><cr> :noh<cr>
  175.  
  176. " Smart way to move between windows
  177. map <C-j> <C-W>j
  178. map <C-k> <C-W>k
  179. map <C-h> <C-W>h
  180. map <C-l> <C-W>l
  181.  
  182. " Mappings to access buffers (don't use "\p" because a
  183. " delay before pressing "p" would accidentally paste).
  184. " ,l       : list buffers
  185. " ,b ,f ,g : go back/forward/last-used
  186. " ,1 ,2 ,3 : go to buffer 1/2/3 etc
  187. nnoremap <Leader>l :ls<CR>
  188. nnoremap <Leader>b :bp<CR>
  189. nnoremap <Leader>f :bn<CR>
  190. nnoremap <Leader>g :e#<CR>
  191. nnoremap <Leader>1 :1b<CR>
  192. nnoremap <Leader>2 :2b<CR>
  193. nnoremap <Leader>3 :3b<CR>
  194. nnoremap <Leader>4 :4b<CR>
  195. nnoremap <Leader>5 :5b<CR>
  196. nnoremap <Leader>6 :6b<CR>
  197. nnoremap <Leader>7 :7b<CR>
  198. nnoremap <Leader>8 :8b<CR>
  199. nnoremap <Leader>9 :9b<CR>
  200. nnoremap <Leader>0 :10b<CR>
  201.  
  202. " Close the current buffer. Bclose defined below.
  203. " dovrebbe già esistere in bufkill.vim
  204. " map <leader>bd :Bclose<cr>
  205.  
  206. " Use the arrows to do something useful
  207. map <right> :bn<cr>
  208. map <left> :bp<cr>
  209.  
  210. " MiniBufExplorer settings
  211. let g:miniBufExplModSelTarget = 1
  212. let g:miniBufExplorerMoreThanOne = 2
  213. let g:miniBufExplModSelTarget = 0
  214. let g:miniBufExplUseSingleClick = 1
  215. let g:miniBufExplMapWindowNavVim = 1
  216.  
  217. " Change directory to the file I'm editing
  218. "autocmd BufEnter * lcd %:p:h
  219. " When pressing <leader>cd switch to the directory of the open buffer
  220. map <leader>cd :cd %:p:h<cr>
  221.  
  222. " Function to close buffer?
  223. command! Bclose call <SID>BufcloseCloseIt()
  224. function! <SID>BufcloseCloseIt()
  225.    let l:currentBufNum = bufnr("%")
  226.    let l:alternateBufNum = bufnr("#")
  227.  
  228.    if buflisted(l:alternateBufNum)
  229.      buffer #
  230.    else
  231.      bnext
  232.    endif
  233.  
  234.    if bufnr("%") == l:currentBufNum
  235.      new
  236.    endif
  237.  
  238.    if buflisted(l:currentBufNum)
  239.      execute("bdelete! ".l:currentBufNum)
  240.    endif
  241. endfunction
  242.  
  243. " Specify the behavior when switching between buffers
  244. try
  245.     set switchbuf=usetab
  246.     set stal=2
  247. catch
  248. endtry
  249.  
  250. nnoremap <C-e> 3<C-e>
  251. nnoremap <C-y> 3<C-y>
  252.  
  253.  
  254. " Always hide the statusline
  255. set laststatus=2
  256.  
  257. " Format the statusline
  258. set statusline=\ %F%m%r%h\ %w\ \ [%Y]\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c
  259. "set statusline=%F%m%w\ Line:\ %l\/%L[%p%%]\ Col:\ %c\ Buf:\ #%n\ [%Y]\ [\%03.3b]\[\%02.2B]
  260.  
  261. function! CurDir()
  262.     let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g")
  263.     return curdir
  264. endfunction
  265.  
  266. " tab labels show the filename without path(tail)
  267. set guitablabel=%N/\ %t\ %M
  268.  
  269. """ Windows
  270. if exists(":tab")                       " Try to move to other windows if changing buf
  271.     set switchbuf=useopen,usetab
  272. else                                    " Try other windows & tabs if available
  273.     set switchbuf=useopen
  274. endif
  275.  
  276. """" Messages, Info, Status
  277. set shortmess+=a                        " Use [+] [RO] [w] for modified, read-only, modified
  278. set report=0                            " Notify me whenever any lines have changed
  279. set confirm                             " Y-N-C prompt if closing with unsaved changes
  280.  
  281. " we don't want to edit these type of files
  282. set wildignore=*.o,*.obj,*.bak,*.exe,*.pyc,*.swp
  283.  
  284. """" Coding
  285. set history=1000                            " 1000 Lines of history
  286. set showfulltag                         " Show more information while completing tags
  287.  
  288.  
  289. " taglist plugin settings
  290. "nnoremap <silent> <F8> :TlistToggle<CR>
  291. let Tlist_Exit_OnlyWindow = 1 "exit if taglist is last window open
  292. let Tlist_Show_One_File = 1 "only show tags for current buffer
  293. let Tlist_Enable_Fold_Column = 0  "no fold column (only showing one file)
  294.  
  295. " OmniCppComplete
  296. let OmniCpp_NamespaceSearch = 1
  297. let OmniCpp_GlobalScopeSearch = 1
  298. let OmniCpp_ShowAccess = 1
  299. let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
  300. let OmniCpp_MayCompleteDot = 1 " autocomplete after .
  301. let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
  302. let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
  303. let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
  304. " automatically open and close the popup menu / preview window
  305. au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
  306. set completeopt=menuone,menu,longest,preview
  307.  
  308. let g:sparkupNextMapping = '<c-x>'
  309.  
  310. " SuperTab settings
  311. let g:SuperTabDefaultCompletionType = '<c-x><c-o>'
  312.  
  313. """"" Folding
  314. set foldmethod=syntax                   " By default, use syntax to determine folds
  315. set foldlevelstart=99                   " All folds open by default
  316.  
  317.  
  318.  
  319. " Function to highlight character beyond column 79
  320. " activate it with ,h
  321. nnoremap <leader>h :call ToggleOverLengthHighlight()<CR>
  322. let g:overlength_enabled = 0
  323. " set the highlight color
  324. highlight OverLength ctermbg=red guibg=red
  325.  
  326. function! ToggleOverLengthHighlight()
  327.     if g:overlength_enabled == 0
  328.         match OverLength /\%79v.*/
  329.         let g:overlength_enabled = 1
  330.         echo 'OverLength highlighting turned on'
  331.     else
  332.         match
  333.         let g:overlength_enabled = 0
  334.         echo 'OverLength highlighting turned off'
  335.     endif
  336. endfunction
  337.  
  338.  
  339. " in visual mode press Ctrl r to start substituting text
  340. vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
  341.  
  342. " PHP Code Sniffer binary (default = "phpcs")
  343. let g:phpqa_codesniffer_cmd='vendor/bin/phpcs'
  344.  
  345. " PHP Mess Detector binary (default = "phpmd")
  346. let g:phpqa_messdetector_cmd='vendor/bin/phpmd'
  347.  
  348.  
  349. set relativenumber
  350.  
  351. " important
  352. " moving around, searching and patterns
  353. " tags
  354. " displaying text
  355. " syntax, highlighting and spelling
  356. " multiple windows
  357. " multiple tab pages
  358. " terminal
  359. " using the mouse
  360. " printing
  361. " messages and info
  362. " selecting text
  363. " editing text
  364. " tabs and indenting
  365. " folding
  366. " diff mode
  367. " mapping
  368.  
  369. " toggle the tag list
  370. nmap <Leader>tl :TlistToggle<CR>
  371.  
  372. " reading and writing files
  373. " the swap file
  374. " command line editing
  375. " executing external commands
  376. " running make and jumping to errors
  377. " language specific
  378. " multi-byte characters
  379. " various
  380.  
  381.  
  382.  
  383. " TagList options
  384.  
  385. " set the names of flags
  386. let tlist_php_settings = 'php;c:class;f:function;d:constant;p:property'
  387. " close all folds except for current file
  388. let Tlist_File_Fold_Auto_Close = 1
  389. " make tlist pane active when opened
  390. let Tlist_GainFocus_On_ToggleOpen = 1
  391. " width of window
  392. let Tlist_WinWidth = 60
  393. " close tlist when a selection is made
  394. let Tlist_Close_On_Select = 1
  395. " show the prototype
  396. let Tlist_Display_Prototype = 1
  397. " show tags only for current buffer
  398. let Tlist_Show_One_File = 1
  399.  
  400. " Taglist variables
  401. " Display function name in status bar:
  402. let g:ctags_statusline=1
  403. " Automatically start script
  404. let generate_tags=1
  405. " Displays taglist results in a vertical windows:
  406. let Tlist_Use_Horiz_Window=0
  407. " Shorter commands to toggle Taglist display
  408. nnoremap TT :TlistToggle<CR>
  409. map <F4> :TlistToggle<CR>
  410. " Various Taglist display config:
  411. let Tlist_Use_Right_Windows = 1
  412. let Tlist_Compact_Format = 1
  413. let Tlist_Exit_OnlyWindow = 1
  414. let Tlist_GainFocus_On_ToggleOpen = 1
  415. let Tlist_File_Fold_Auto_Close = 1
  416.  
  417. " Ctags options
  418. nmap <Leader>tf :call CtagsFind(expand('<cword>'))<CR>
  419. com! -nargs=+ Tf :call CtagsFind("<args>")
  420. " split window and search for tag
  421. nmap <Leader>ts :exe('stj '.expand('<cword>'))<CR>
  422. set tags=tags;/
  423.  
  424. " open new tab and search for tag
  425. "
  426. fun! CtagsFind(keyword)
  427.     tabe
  428.     exe "tj ".a:keyword
  429. endfunction
  430.  
  431. " TagBar
  432. nmap <F8> :TagbarToggle<CR>
  433.  
  434. " CtrlP
  435. let g:ctrlp_map = ',t'
  436. nnoremap <silent> ,t :CtrlP<CR>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement