Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.48 KB | None | 0 0
  1. " Description: A minimal, but feature rich, example .vimrc. If you are a
  2. " newbie, basing your first .vimrc on this file is a good choice.
  3. " If you're a more advanced user, building your own .vimrc based
  4. " on this file is still a good idea.
  5. " Lots of options set via lots of good ideas found on the web
  6. "
  7.  
  8. "------------------------------------------------------------
  9. " Features {{{1
  10. "
  11. " These options and commands enable some very useful features in Vim, that
  12. " no user should have to live without.
  13. "
  14. " Now any plugins you wish to install can be extracted to a subdirectory under
  15. " ~/.vim/bundle
  16.  
  17. if has ("win32")
  18. set runtimepath+=$HOME/vimfiles/bundle/
  19. else
  20. set runtimepath+=$HOME/.vim/bundle/
  21. endif
  22.  
  23. " Use pathogen to easily modify the runtime path to include all
  24. " plugins under the ~/.vim/bundle directory
  25. call pathogen#helptags()
  26. call pathogen#runtime_append_all_bundles()
  27.  
  28. " Set 'nocompatible' to ward off unexpected things that your distro might
  29. " have made, as well as sanely reset options when re-sourcing .vimrc
  30. set nocompatible
  31.  
  32. " Attempt to determine the type of a file based on its name and possibly its
  33. " contents. Use this to allow intelligent auto-indenting for each filetype,
  34. " and for plugins that are filetype specific.
  35. filetype indent plugin on
  36.  
  37. " Enable syntax highlighting
  38. syntax on
  39.  
  40. " Allows saving of commands when you forget to use sudo Vim with a W.
  41. " utilizes tee hack, for more about tee, "man tee"
  42. command! W w !sudo tee % > /dev/null
  43. " allows M$ commands like Copy/paste keyboard shortcuts
  44. behave mswin
  45.  
  46. "------------------------------------------------------------
  47. " Must have options {{{1
  48. "
  49. " These are highly recommended options.
  50.  
  51. " Vim with default settings does not allow easy switching between multiple files
  52. " in the same editor window. Users can use multiple split windows or multiple
  53. " tab pages to edit multiple files, but it is still best to enable an option to
  54. " allow easier switching between files.
  55. "
  56. " One such option is the 'hidden' option, which allows you to re-use the same
  57. " window and switch from an unsaved buffer without saving it first. Also allows
  58. " you to keep an undo history for multiple files when re-using the same window
  59. " in this way. Note that using persistent undo also lets you undo in multiple
  60. " files even in the same window, but is less efficient and is actually designed
  61. " for keeping undo history after closing Vim entirely. Vim will complain if you
  62. " try to quit without saving, and swap files will keep you safe if your computer
  63. " crashes.
  64. set hidden
  65.  
  66.  
  67. " Note that not everyone likes working this way (with the hidden option).
  68. " Alternatives include using tabs or split windows instead of re-using the same
  69. " window as mentioned above, and/or either of the following options:
  70. " set confirm
  71. " set autowriteall
  72.  
  73. " Better command-line completion
  74. set wildmenu
  75.  
  76. " don't create ~filename backups, very annoying to leave this on and find dozens of extra files scattered about
  77. set nobackup
  78.  
  79.  
  80. "------------------------------------------------------------
  81. " Usability options {{{1
  82. "
  83. " These are options that users frequently set in their .vimrc. Some of them
  84. " change Vim's behaviour in ways which deviate from the true Vi way, but
  85. " which are considered to add usability. Which, if any, of these options to
  86. " use is very much a personal preference, but they are harmless.
  87.  
  88. " Use case insensitive search, except when using capital letters
  89. set ignorecase
  90. set smartcase
  91.  
  92. " Allow backspacing over autoindent, line breaks and start of insert action
  93. set backspace=indent,eol,start
  94.  
  95. " When opening a new line and no filetype-specific indenting is enabled, keep
  96. " the same indent as the line you're currently on. Useful for READMEs, etc.
  97. set autoindent
  98.  
  99. " Stop certain movements from always going to the first character of a line.
  100. " While this behaviour deviates from that of Vi, it does what most users
  101. " coming from other editors would expect.
  102. set nostartofline
  103.  
  104. " Display the cursor position on the last line of the screen or in the status
  105. " line of a window
  106. set ruler
  107.  
  108. " Always display the status line, even if only one window is displayed
  109. set laststatus=2
  110.  
  111. " Instead of failing a command because of unsaved changes, instead raise a
  112. " dialogue asking if you wish to save changed files.
  113. set confirm
  114.  
  115. " Use visual bell instead of beeping when doing something wrong
  116. set visualbell
  117.  
  118. " And reset the terminal code for the visual bell. If visualbell is set, and
  119. " this line is also included, vim will neither flash nor beep. If visualbell
  120. " is unset, this does nothing.
  121. set t_vb=
  122.  
  123. " Enable use of the mouse for all modes
  124. set mouse=a
  125. imap <ScrollWheelUp> <C-Y>
  126. map <ScrollWheelDown> <C-E>
  127. set selectmode-=mouse "Use the mouse just like visual mode, so you can use vim commands on mouse selections, eg. 'x' to cut and 'y' to yank
  128.  
  129. "This is if you have a dark background in your terminal, light is another option
  130. set background=dark
  131. "set background=light
  132.  
  133. " Set the command window height to 2 lines, to avoid many cases of having to
  134. " "press <Enter> to continue"
  135. set cmdheight=2
  136.  
  137. " Display line numbers on the left
  138. set number
  139.  
  140. " Quickly time out on keycodes, but never time out on mappings
  141. set notimeout ttimeout ttimeoutlen=200
  142.  
  143. " Use <F11> to toggle between 'paste' and 'nopaste'
  144. set pastetoggle=<F11>
  145.  
  146. set nowrap " don't wrap lines longer than the screen's width
  147.  
  148. set guioptions+=b " show bottom scrollbar when in gvim
  149.  
  150. set foldmethod=indent " fold code based on indents
  151.  
  152. set nofoldenable " makes sure the code is not folded when first opened, used
  153.  
  154. set scrolloff=4 " Keep 4 lines at minimum above & below the cursor when scrolling around a file
  155.  
  156. set showmatch " Jumps to the other bracket
  157.  
  158. "These options are personal preference
  159.  
  160. set cursorline "Underline the current line the cursor is on.
  161.  
  162. set incsearch ignorecase hlsearch
  163.  
  164. " Press space to clear search highlighting and any message already displayed.
  165. nnoremap <silent> <Space> :silent noh<Bar>echo<CR>
  166.  
  167. "Upgrade the status line to give more usefull information
  168. set statusline=%F\ %m%r%w%y\ %=(%L\ loc)\ [#\%03.3b\ 0x\%02.2B]\ \ %l,%v\ \
  169.  
  170. "Printing (:hardcopy) options
  171. set printoptions=paper:letter,syntax:y,number:y,duplex:off,left:5pc
  172. "------------------------------------------------------------
  173. " Indentation options {{{1
  174. "
  175. " Indentation settings according to personal preference.
  176.  
  177. " Indentation settings for using 4 spaces instead of tabs.
  178. " Do not change 'tabstop' from its default value of 8 with this setup.
  179.  
  180. set shiftwidth=4
  181.  
  182. set softtabstop=4
  183.  
  184. set expandtab
  185.  
  186. " Indentation settings for using hard tabs for indent. Display tabs as
  187. " two characters wide.
  188. "set shiftwidth=2
  189. "set tabstop=2
  190.  
  191.  
  192. "------------------------------------------------------------
  193. " Mappings {{{1
  194. "
  195. " Useful mappings
  196.  
  197. " Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy,
  198. " which is the default
  199. map Y y$
  200.  
  201. " Map <C-L> (redraw screen) to also turn off search highlighting until the
  202. " next search
  203. nnoremap <C-L> :nohl<CR><C-L>
  204.  
  205. " toggle pasting on and off
  206. set pastetoggle=<F2>
  207.  
  208.  
  209. "------------------------------------------------------------
  210. " Colors {{{1
  211.  
  212.  
  213.  
  214. " if terminal supports 256 coloring
  215. if &term =~ "xterm-256color"
  216. "For bright monitors, 'ir-black' is nice to the eyes, enable 256 mode an
  217. colorscheme ir_black
  218. endif
  219.  
  220. " if xterm, assume color is OK; btw =~ means ignore case and also somehow
  221. " xterm-256color was still being caught by it
  222. if &term == "xterm" || &term == "xterm-color"
  223. set t_Co=8
  224. "Tell vim it's ok to send color
  225. if &term =~ "xterm"
  226. set term=xterm-color
  227. endif
  228. "All around well balanced colorscheme
  229. " colorscheme ron
  230. "For med-dark monitors 'ron' or 'koehler' colorschemes are great
  231. colorscheme koehler
  232. endif
  233.  
  234. " for screen sessions
  235. if &term == "screen"
  236. set t_Co=256
  237. endif
  238.  
  239. if has('gui_running')
  240. set t_Co=256
  241. colorscheme ir_black
  242. endif
  243.  
  244. "------------------------------------------------------------
  245. " Syntastic configs
  246. "
  247.  
  248. " let g:syntastic_check_on_open=1
  249.  
  250. let g:syntastic_enable_signs=1
  251.  
  252. " let g:syntastic_auto_jump=1
  253.  
  254. let g:syntastic_stl_format = '[%E{Err: %fe #%e}%B{, }%W{Warn: %fw #%w}]'
  255.  
  256. set statusline+=%#warningmsg#
  257.  
  258. set statusline+=%{SyntasticStatuslineFlag()}
  259.  
  260. set statusline+=%*
  261.  
  262. " and A jsHint config
  263. let g:js_indent_log = 1
  264.  
  265. "------------------------------------------------------------
  266. "
  267. " Autocompletion
  268. set ofu=syntaxcomplete#Complete
  269.  
  270. autocmd FileType php set omnifunc=phpcomplete#CompletePHP
  271.  
  272. autocmd FileType phtml set omnifunc=phpcomplete#CompletePHP
  273.  
  274. autocmd FileType python set omnifunc=pythoncomplete#Complete
  275.  
  276. autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
  277.  
  278. autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
  279.  
  280. autocmd FileType css set omnifunc=csscomplete#CompleteCSS
  281.  
  282. autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
  283.  
  284. autocmd FileType c set omnifunc=ccomplete#Complete
  285.  
  286. " disable acp(auto -auto completion popmenu)
  287. let g:acp_enableAtStartup = 0
  288.  
  289. "disable preview menu, because scratch view is annoying?
  290. set completeopt =longest,menuone,menu
  291.  
  292. highlight Pmenu guibg=brown gui=bold
  293.  
  294. highlight Pmenu ctermbg=238 gui=bold
  295.  
  296. " remap ctrl-x + ctrl-o to SuperTabfor omnicomplete
  297. let g:SuperTabDefaultCompletionType = "<C-x><C-o>"
  298.  
  299. " lets SuperTab decide which completion mode to use and should play well with OmniCompletion
  300. let g:SuperTabDefaultCompletionType = "context"
  301.  
  302. " When enabled, supertab will attempt to close vim's completion preview window
  303. " when the completion popup closes (completion is finished or canceled).
  304. let g:SuperTabClosePreviewOnPopupClose = 1
  305.  
  306. "----------------------------------------------------------
  307. " Node-complete
  308. "
  309. " add node library to dict
  310. au FileType javascript set dictionary+=$HOME/.vim/dict/node.dict
  311. let g:nodejs_complete_config = {'js_compl_fn': 'jscomplete#CompleteJS', 'max_node_compl_len':15}
  312. "------------------------------------------------------------
  313. " Misc
  314. "
  315.  
  316. "If your having trouble with the backspace character, try uncommenting these
  317. "imap <C-?> <BS>
  318. "imap <C-H> <BS>
  319. "inoremap <BS>
  320.  
  321. if has("autocmd")
  322. " Have Vim jump to the last position when reopening a file
  323. au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
  324. \| exe "normal! g'\"" | endif
  325. " Support mips.asm files
  326. autocmd BufNewFile,BufRead *.mips.asm set syntax=mips.vim
  327. " Trim Trailing white space on general files
  328. autocmd FileType c,cpp,java,php,js,css,xml,xsl,s autocmd BufWritePre * :
  329. endif
  330.  
  331. " Support for Gundo, a visual & mini tree structure of document changes
  332. nnoremap <F5> :GundoToggle<CR>
  333. " Set persistant undo
  334. set undodir=~/.vim/undodir
  335. set undofile
  336.  
  337. " spelling
  338. if v:version >= 700
  339. " Enable spell check for text files
  340. autocmd BufNewFile,BufRead *.txt setlocal spell spelllang=en
  341. endif
  342.  
  343.  
  344. if exists("+showtabline")
  345. function MyTabLine()
  346. let s = ''
  347. let t = tabpagenr()
  348. let i = 1
  349. while i <= tabpagenr('$')
  350. let buflist = tabpagebuflist(i)
  351. let winnr = tabpagewinnr(i)
  352. let s .= '%' . i . 'T'
  353. let s .= (i == t ? '%1*' : '%2*')
  354. let s .= ' '
  355. let s .= i . ')'
  356. let s .= ' %*'
  357. let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
  358. let file = bufname(buflist[winnr - 1])
  359. let file = fnamemodify(file, ':p:t')
  360. if file == ''
  361. let file = '[No Name]'
  362. endif
  363. let s .= file
  364. let i = i + 1
  365. endwhile
  366. let s .= '%T%#TabLineFill#%='
  367. let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
  368. return s
  369. endfunction
  370. set stal=2
  371. set tabline=%!MyTabLine()
  372. endif
  373.  
  374. set tags=./tags,tags;$HOME
  375. set viminfo='10,\"100,:20,%,n~/.viminfo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement