git_complete 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. " based on http://github.com/jferris/config_files/blob/master/vimrc
  2. " Use Vim settings, rather then Vi settings (much better!).
  3. " This must be first, because it changes other options as a side effect.
  4. set nocompatible
  5. " allow backspacing over everything in insert mode
  6. set backspace=indent,eol,start
  7. set nobackup
  8. set nowritebackup
  9. set history=50 " keep 50 lines of command line history
  10. set ruler " show the cursor position all the time
  11. set showcmd " display incomplete commands
  12. set incsearch " do incremental searching
  13. " Don't use Ex mode, use Q for formatting
  14. map Q gq
  15. " This is an alternative that also works in block mode, but the deleted
  16. " text is lost and it only works for putting the current register.
  17. "vnoremap p "_dp
  18. " Switch syntax highlighting on, when the terminal has colors
  19. " Also switch on highlighting the last used search pattern.
  20. if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on")
  21. syntax on
  22. set hlsearch
  23. endif
  24. " Switch wrap off for everything
  25. set nowrap
  26. " Only do this part when compiled with support for autocommands.
  27. if has("autocmd")
  28. " Enable file type detection.
  29. " Use the default filetype settings, so that mail gets 'tw' set to 72,
  30. " 'cindent' is on in C files, etc.
  31. " Also load indent files, to automatically do language-dependent indenting.
  32. filetype plugin indent on
  33. " Set File type to 'text' for files ending in .txt
  34. autocmd BufNewFile,BufRead *.txt setfiletype text
  35. " Enable soft-wrapping for text files
  36. autocmd FileType text,markdown,html,xhtml,eruby setlocal wrap linebreak nolist
  37. " Put these in an autocmd group, so that we can delete them easily.
  38. augroup vimrcEx
  39. au!
  40. " For all text files set 'textwidth' to 78 characters.
  41. " autocmd FileType text setlocal textwidth=78
  42. " When editing a file, always jump to the last known cursor position.
  43. " Don't do it when the position is invalid or when inside an event handler
  44. " (happens when dropping a file on gvim).
  45. autocmd BufReadPost *
  46. \ if line("'\"") > 0 && line("'\"") <= line("$") |
  47. \ exe "normal g`\"" |
  48. \ endif
  49. " Automatically load .vimrc source when saved
  50. autocmd BufWritePost .vimrc source $MYVIMRC
  51. augroup END
  52. else
  53. set autoindent " always set autoindenting on
  54. endif " has("autocmd")
  55. " if has("folding")
  56. " set foldenable
  57. " set foldmethod=syntax
  58. " set foldlevel=1
  59. " set foldnestmax=2
  60. " set foldtext=strpart(getline(v:foldstart),0,50).'\ ...\ '.substitute(getline(v:foldend),'^[\ #]*','','g').'\ '
  61. " endif
  62. " Softtabs, 2 spaces
  63. set tabstop=2
  64. set shiftwidth=2
  65. set expandtab
  66. " Always display the status line
  67. set laststatus=2
  68. " \ is the leader character
  69. let mapleader = ","
  70. " Edit the README_FOR_APP (makes :R commands work)
  71. map <Leader>R :e doc/README_FOR_APP<CR>
  72. " Leader shortcuts for Rails commands
  73. map <Leader>m :Rmodel
  74. map <Leader>c :Rcontroller
  75. map <Leader>v :Rview
  76. map <Leader>u :Runittest
  77. map <Leader>f :Rfunctionaltest
  78. map <Leader>tm :RTmodel
  79. map <Leader>tc :RTcontroller
  80. map <Leader>tv :RTview
  81. map <Leader>tu :RTunittest
  82. map <Leader>tf :RTfunctionaltest
  83. map <Leader>sm :RSmodel
  84. map <Leader>sc :RScontroller
  85. map <Leader>sv :RSview
  86. map <Leader>su :RSunittest
  87. map <Leader>sf :RSfunctionaltest
  88. " Hide search highlighting
  89. map <Leader>h :set invhls <CR>
  90. " Opens an edit command with the path of the currently edited file filled in
  91. " Normal mode: <Leader>e
  92. map <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
  93. " Opens a tab edit command with the path of the currently edited file filled in
  94. " Normal mode: <Leader>t
  95. map <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
  96. " Inserts the path of the currently edited file into a command
  97. " Command mode: Ctrl+P
  98. cmap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
  99. " Duplicate a selection
  100. " Visual mode: D
  101. vmap D y'>p
  102. " Press Shift+P while in visual mode to replace the selection without
  103. " overwriting the default register
  104. vmap P p :call setreg('"', getreg('0')) <CR>
  105. " For Haml
  106. au! BufRead,BufNewFile *.haml setfiletype haml
  107. " No Help, please
  108. nmap <F1> <Esc>
  109. " Press ^F from insert mode to insert the current file name
  110. imap <C-F> <C-R>=expand("%")<CR>
  111. " Maps autocomplete to tab
  112. imap <Tab> <C-N>
  113. imap <C-L> <Space>=><Space>
  114. " Display extra whitespace
  115. " set list listchars=tab:Èá,trail:á
  116. " Edit routes
  117. command! Rroutes :e config/routes.rb
  118. command! Rschema :e db/schema.rb
  119. " Local config
  120. if filereadable(".vimrc.local")
  121. source .vimrc.local
  122. endif
  123. " Use Ack instead of Grep when available
  124. if executable("ack")
  125. set grepprg=ack\ -H\ --nogroup\ --nocolor\ --ignore-dir=tmp\ --ignore-dir=coverage
  126. endif
  127. " Color scheme
  128. " colorscheme vividchalk
  129. " highlight NonText guibg=#060606
  130. " highlight Folded guibg=#0A0A0A guifg=#9090D0
  131. " Numbers
  132. set number
  133. set numberwidth=5
  134. " Snippets are activated by Shift+Tab
  135. let g:snippetsEmu_key = "<S-Tab>"
  136. " Tab completion options
  137. " (only complete to the longest unambiguous match, and show a menu)
  138. set completeopt=longest,menu
  139. set wildmode=list:longest,list:full
  140. set complete=.,t
  141. " case only matters with mixed case expressions
  142. set ignorecase
  143. set smartcase
  144. " Tags
  145. let g:Tlist_Ctags_Cmd="ctags --exclude='*.js'"
  146. set tags=./tags;
  147. let g:fuf_splitPathMatching=1
  148. " Open URL
  149. command -bar -nargs=1 OpenURL :!open <args>
  150. function! OpenURL()
  151. let s:uri = matchstr(getline("."), '[a-z]*:\/\/[^ >,;:]*')
  152. echo s:uri
  153. if s:uri != ""
  154. exec "!open \"" . s:uri . "\""
  155. else
  156. echo "No URI found in line."
  157. endif
  158. endfunction
  159. map <Leader>w :call OpenURL()<CR>