Guest User

Untitled

a guest
Jul 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.26 KB | None | 0 0
  1. set nocompatible " We don't want vi compatibility.
  2.  
  3. filetype on " Automatically detect file types.
  4.  
  5. " Add recently accessed projects menu (project plugin)
  6. set viminfo^=!
  7.  
  8. " maps esc to break out of autocompletion and reset to
  9. " original word
  10. inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"
  11.  
  12. " Minibuffer Explorer Settings
  13. "let g:miniBufExplMapWindowNavVim = 1
  14. "let g:miniBufExplMapWindowNavArrows = 1
  15. let g:miniBufExplMapCTabSwitchBufs=1
  16. let g:miniBufExplorerMoreThanOne=1
  17. let g:miniBufExplMaxSize=2
  18. let g:miniBufExplTabWrap=1
  19. "
  20. " alt+n or alt+p to navigate between entries in QuickFix
  21. " (this isn't working, think it's a shell thing with alt)
  22. map <silent> <m-p> :cp <cr>
  23. map <silent> <m-n> :cn <cr>
  24.  
  25. " mapping for modified recently menu to \r
  26. map <silent> <Leader>r :MRU<cr>
  27.  
  28. " Change which file opens after executing :Rails command
  29. let g:rails_default_file='config/database.yml'
  30.  
  31. set cf " Enable error files & error jumping.
  32. set clipboard+=unnamed " Yanks go on clipboard instead.
  33. set history=256 " Number of things to remember in history.
  34. set autowrite " Writes on make/shell commands
  35. set ruler " Ruler on
  36. set nu " Line numbers on
  37. set nowrap " Line wrapping off
  38. set timeoutlen=350 " Time to wait after ESC (default causes an annoying delay)
  39.  
  40. " Formatting (some of these are for coding in C and C++)
  41. set ts=2 " Tabs are 2 spaces
  42. set bs=2 " Backspace over everything in insert mode
  43. set shiftwidth=2 " Tabs under smart indent
  44. set softtabstop=2
  45. set expandtab
  46. set smarttab
  47. set autoindent
  48. set nocp incsearch
  49. set hlsearch
  50. set formatoptions=tcqr
  51. set cinoptions=:0,p0,t0
  52. set cinwords=if,else,while,do,for,switch,case
  53. set cindent
  54.  
  55. " Visual
  56. set showmatch " Show matching brackets.
  57. set showcmd "show incomplete cmds down the bottom
  58. set showmode "show current mode down the bottom
  59. set mat=5 " Bracket blinking.
  60. set list
  61. " Show $ at end of line and trailing space as ~
  62. set lcs=tab:\ \ ,eol:$,trail:~,extends:>,precedes:<
  63. set noerrorbells " No noise.
  64. set laststatus=2 " Always show status line.
  65.  
  66. " macro to automatically switch directories when opening files
  67. " autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9]*://" | lcd %:p:h | endif
  68.  
  69. " easy mapping for cd to current file directory (to avoid bugs with plugins
  70. " that don't expect auto cd to happen)
  71. map <silent> ,cd :cd %:p:h<CR>
  72.  
  73. let g:plaintex_delimiters = 0
  74.  
  75. " color the nasty popup menu pink. doesn't always work
  76. "highlight Pmenu ctermbg=238 gui=bold
  77. highlight Pmenu ctermfg=0 ctermbg=3
  78. highlight PmenuSel ctermfg=0 ctermbg=7
  79.  
  80. " cheap hack to force fuzzyfinder to reinit.
  81. " there's probably a right way to do this, didn't see it
  82. function! ResetFuzzyFinderToCWD()
  83. ruby @finder = nil
  84. let g:fuzzy_roots = [getcwd()]
  85. echo "Resetting FuzzyFinder root to " . getcwd()
  86. endfunction
  87.  
  88. map <Leader>f :call ResetFuzzyFinderToCWD()<cr>
  89.  
  90. " autocmd to source vimrc when it's saved
  91. "au! BufWritePost .vimrc source %
  92.  
  93. autocmd BufNewFile *.as set filetype=javascript
  94. autocmd BufRead *.as set filetype=javascript
  95.  
  96. nnoremap ,, :buffers<CR>:bu<space>
  97.  
  98. " hacky thing I did to MRU that opens most recent file
  99. " (works mostly like <C-^> but works on closed files)
  100. command! BB MRURecent
  101. nmap ,b :BB<CR>
  102.  
  103. " left/right arrows change buffers
  104. map <C-right> :bn<CR>
  105. map <C-left> :bp<CR>
  106. map <C-h> :bp<CR>
  107. map <C-l> :bn<CR>
  108.  
  109. " comma+dir for directional buffer nav
  110. nmap ,k <C-W>k
  111. nmap ,j <C-W>j
  112. nmap ,h <C-W>h
  113. nmap ,l <C-W>l
  114.  
  115. " because I hate typing C-d
  116. nmap <C-j> <C-d>
  117. nmap <C-k> <C-u>
  118.  
  119. ",s to pull word under cursor into a search/replace (global)
  120. nmap ,s :%s/<c-r><c-w>//g<Left><Left>
  121.  
  122. "allow backspacing over everything in insert mode
  123. set backspace=indent,eol,start
  124. set linebreak "wrap lines at convenient points
  125.  
  126. "statusline setup
  127. set statusline+=%n: "buffer number
  128. set statusline+=%f "relative filename
  129.  
  130. "display a warning if fileformat isnt unix
  131. "set statusline+=%#warningmsg#
  132. "set statusline+=%{&ff!='unix'?'['.&ff.']':''}
  133. "set statusline+=%*
  134.  
  135. "display a warning if file encoding isnt utf-8
  136. "set statusline+=%#warningmsg#
  137. "set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
  138. "set statusline+=%*
  139.  
  140. "set statusline+=%y "filetype
  141. set statusline+=%m "modified flag
  142.  
  143. "display a warning if &et is wrong, or we have mixed-indenting
  144. "set statusline+=%#error#
  145. "set statusline+=%{StatuslineTabWarning()}
  146. "set statusline+=%*
  147.  
  148. "set statusline+=%{StatuslineTrailingSpaceWarning()}
  149.  
  150. "display a warning if &paste is set
  151. "set statusline+=%#error#
  152. "set statusline+=%{&paste?'[paste]':''}
  153. "set statusline+=%*
  154.  
  155. set statusline+=%= "left/right separator
  156. set statusline+=%{StatuslineCurrentHighlight()}\ \ "current highlight
  157. set statusline+=%c, "cursor column
  158. set statusline+=%l/%L "cursor line/total lines
  159. set statusline+=\ %P "percent through file
  160.  
  161. "recalculate the trailing whitespace warning when idle, and after saving
  162. autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
  163.  
  164. "return '[\s]' if trailing white space is detected
  165. "return '' otherwise
  166. function! StatuslineTrailingSpaceWarning()
  167. if !exists("b:statusline_trailing_space_warning")
  168. if search('\s\+$', 'nw') != 0
  169. let b:statusline_trailing_space_warning = '[\s]'
  170. else
  171. let b:statusline_trailing_space_warning = ''
  172. endif
  173. endif
  174. return b:statusline_trailing_space_warning
  175. endfunction
  176.  
  177.  
  178. "return the syntax highlight group under the cursor ''
  179. function! StatuslineCurrentHighlight()
  180. let name = synIDattr(synID(line('.'),col('.'),1),'name')
  181. if name == ''
  182. return ''
  183. else
  184. return '[' . name . ']'
  185. endif
  186. endfunction
  187.  
  188. "recalculate the tab warning flag when idle and after writing
  189. autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
  190.  
  191. "return '[&et]' if &et is set wrong
  192. "return '[mixed-indenting]' if spaces and tabs are used to indent
  193. "return an empty string if everything is fine
  194. function! StatuslineTabWarning()
  195. if !exists("b:statusline_tab_warning")
  196. let tabs = search('^\t', 'nw') != 0
  197. let spaces = search('^ ', 'nw') != 0
  198.  
  199. if tabs && spaces
  200. let b:statusline_tab_warning = '[mixed-indenting]'
  201. elseif (spaces && !&et) || (tabs && &et)
  202. let b:statusline_tab_warning = '[&et]'
  203. else
  204. let b:statusline_tab_warning = ''
  205. endif
  206. endif
  207. return b:statusline_tab_warning
  208. endfunction
  209.  
  210. "folding settings
  211. set foldmethod=indent "fold based on indent
  212. set foldnestmax=3 "deepest fold is 3 levels
  213. set nofoldenable "dont fold by default
  214.  
  215. set wildmode=list:longest "make cmdline tab completion similar to bash
  216. set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
  217. set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing
  218.  
  219. "display tabs and trailing spaces
  220. set listchars=tab:\ \ ,extends:>,precedes:<
  221.  
  222. set formatoptions-=o "dont continue comments when pushing o/O
  223.  
  224. "vertical/horizontal scroll off settings
  225. set scrolloff=3
  226. set sidescrolloff=7
  227. set sidescroll=1
  228.  
  229. "load ftplugins and indent files
  230. filetype plugin on
  231. filetype indent on
  232.  
  233. "turn on syntax highlighting
  234. syntax on
  235. set t_Co=256
  236.  
  237. "hide buffers when not displayed
  238. set hidden
  239.  
  240. "dont load csapprox if we no gui support - silences an annoying warning
  241. if !has("gui")
  242. let g:CSApprox_loaded = 1
  243. else
  244. if has("gui_gnome")
  245. set term=gnome-256color
  246. syntax on
  247. else
  248. set guitablabel=%M%t
  249. set lines=40
  250. set columns=115
  251. endif
  252. if has("gui_mac") || has("gui_macvim")
  253. set guifont=Monaco:h16
  254. endif
  255. if has("gui_win32") || has("gui_win32s")
  256. set guifont=Consolas:h12
  257. set enc=utf-8
  258. endif
  259. endif
  260.  
  261. set mousehide " Hide mouse after chars typed
  262. set mouse=a " Mouse in all modes
  263. set guioptions-=r
  264. set guioptions-=R
  265. set guioptions-=l
  266. set guioptions-=L
  267. set guioptions-=T
  268. " note for whatever reason ttymouse must be set after term is set
  269. " or it will cause problems with the terminal
  270. set ttymouse=xterm2
  271.  
  272. nmap <silent> <Leader>p :NERDTreeToggle<CR>
  273. nnoremap <silent> ,f :NERDTreeToggle<CR>
  274.  
  275. "make <c-l> clear the highlight as well as redraw
  276. "nnoremap <C-L> :nohls<CR><C-L>
  277. "inoremap <C-L> <C-O>:nohls<CR>
  278.  
  279. "map to fuzzy finder text mate stylez
  280. nnoremap <c-f> :FuzzyFinderTextMate<CR>
  281.  
  282. "map Q to something useful
  283. noremap <silent> Q :bd<CR>
  284.  
  285. "make Y consistent with C and D
  286. nnoremap Y y$
  287.  
  288. "visual search mappings
  289. function! s:VSetSearch()
  290. let temp = @@
  291. norm! gvy
  292. let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
  293. let @@ = temp
  294. endfunction
  295. vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR>
  296. vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR>
  297.  
  298. "jump to last cursor position when opening a file
  299. "dont do it when writing a commit log entry
  300. autocmd BufReadPost * call SetCursorPosition()
  301. function! SetCursorPosition()
  302. if &filetype !~ 'commit\c'
  303. if line("'\"") > 0 && line("'\"") <= line("$")
  304. exe "normal g`\""
  305. endif
  306. end
  307. endfunction
  308.  
  309. "define :HighlightExcessColumns command to highlight the offending parts of
  310. "lines that are "too long". where "too long" is defined by &textwidth or an
  311. "arg passed to the command
  312. command! -nargs=? HighlightExcessColumns call s:HighlightExcessColumns('<args>')
  313. function! s:HighlightExcessColumns(width)
  314. let targetWidth = a:width != '' ? a:width : &textwidth
  315. if targetWidth > 0
  316. exec 'match Todo /\%>' . (targetWidth+1) . 'v/'
  317. else
  318. echomsg "HighlightExcessColumns: set a &textwidth, or pass one in"
  319. endif
  320. endfunction
  321.  
  322. " akitaonrails vimfies suggestions
  323. let g:fuzzy_ignore = "gems/*"
  324.  
  325. " command to get urls
  326. let g:netrw_http_cmd = "wget -q -O"
  327.  
  328. "colorscheme brookstream
  329. "colorscheme wombat
  330. colorscheme vilight
  331. "colorscheme vividchalk
  332. "colorscheme desert256
  333. "colorscheme fnaqevan " like dante but more pastel and less contrast
  334. " colorscheme dante " orange/blue/green, med contrast
  335. " colorscheme neverness " gray/blue/green, med contrast
  336. " colorscheme vibrantink " multi, high contrast
  337. " colorscheme blacksea " multi, high contrast
  338. " colorscheme darkdot " gray bg, blue/grayish, med/high contrast
  339. " colorscheme camo " browns/greens
  340. "colorscheme chlordane " greens/grays
  341. "colorscheme jammy " gray, pastel
  342. "colorscheme metacosm " high contrast
Advertisement
Add Comment
Please, Sign In to add comment