pastebin - collaborative debugging tool
vi.kpaste.net RSS


.vimrc
Posted by Anonymous on Wed 25th Nov 2015 16:52
raw | new post

  1. """"""""""
  2. " .vimrc "
  3. """"""""""
  4.  
  5. " vim-pathogen
  6. " https://github.com/tpope/vim-pathogen
  7. " How-to that I followed: https://gist.github.com/romainl/9970697
  8. execute pathogen#infect()
  9.  
  10.  
  11. " This line should not be removed as it ensures that various options are
  12. " properly set to work with the Vim-related packages available in Debian.
  13. "runtime! debian.vim
  14.  
  15. " Uncomment the next line to make Vim more Vi-compatible
  16. " NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
  17. " options, so any other options should be set AFTER setting 'compatible'.
  18. "set nocompatible
  19.  
  20.  
  21. " Filetype - http://vimhelp.appspot.com/filetype.txt.html
  22. filetype plugin indent on
  23.  
  24. """""""""""""""""""""""""""""""""""""""""""""""
  25. " Here begins my automated wordcount addition.
  26. " This combines several ideas from:
  27. " http://stackoverflow.com/questions/114431/fast-word-count-function-in-vim
  28. " This function is primarily used in statusline
  29. """""""""""""""""""""""""""""""""""""""""""""""
  30. let g:word_count="<unknown>"
  31. function WordCount()
  32.     return g:word_count
  33. endfunction
  34. function UpdateWordCount()
  35.     let lnum = 1
  36.     let n = 0
  37.     while lnum <= line('$')
  38.         let n = n + len(split(getline(lnum)))
  39.         let lnum = lnum + 1
  40.     endwhile
  41.     let g:word_count = n
  42. endfunction
  43. " Update the count when cursor is idle in command or insert mode.
  44. " Update when idle for 1000 msec (default is 4000 msec).
  45. set updatetime=1000
  46. augroup WordCounter
  47.     au! CursorHold,CursorHoldI * call UpdateWordCount()
  48. augroup END
  49.  
  50.  
  51.  
  52.  
  53. """""""""""""""""
  54. " < COSMETICS > "
  55. """""""""""""""""
  56.  
  57. """ Color management
  58. " vim can autodetect this based on $TERM (e.g. 'xterm-256color')
  59. " but it can be set to force 256 colors
  60. " set t_Co=256
  61. if &t_Co < 256
  62.     colorscheme default
  63.     "set nocursorline " looks bad in this mode
  64. else
  65.     set background=dark
  66.     " let g:solarized_termcolors=256 " instead of 16 color with mapping in terminal
  67.     colorscheme flattened_dark
  68.     " customized colors
  69.     " highlight SignColumn ctermbg=234
  70.     " highlight StatusLine cterm=bold ctermfg=245 ctermbg=235
  71.     " highlight StatusLineNC cterm=bold ctermfg=245 ctermbg=235
  72. endif
  73.  
  74. """ Color overrides
  75.  
  76. " Enable cursorline in insert mode.
  77. autocmd InsertEnter * set cul
  78. autocmd InsertLeave * set nocul
  79.  
  80. " Set cursor colum color
  81. highlight CursorColumn ctermbg=230 guibg=#ffffd7
  82.  
  83. " Instead of red background when spellchecking, do underlines.
  84. " Source - https://github.com/mgedmin/dotvim/blob/master/vimrc#L1270-L1271
  85. highlight SpellBad              cterm=underline ctermfg=red ctermbg=NONE
  86. highlight SpellCap              cterm=underline ctermfg=blue ctermbg=NONE
  87.  
  88.  
  89. """
  90.  
  91. " Vim5 and later versions support syntax highlighting. Uncommenting the next line enables syntax highlighting by default.
  92. if has("syntax")
  93.   syntax on
  94. endif
  95.  
  96. set background=dark     " If using a dark background within the editing area and syntax highlighting turn on this option as well
  97. set number      " Turn line numbers on
  98. set ruler       " Show the cursor position all the time
  99. set showcmd     " Show the commands which you enter in the file - https://www.hscripts.com/tutorials/vim-commands/showcmd.html
  100.  
  101. " Highlight searched text
  102. " Do :nohl to turn it off (for that session).
  103. set hlsearch
  104.  
  105. " Search as you type.
  106. " Vim will start searching when you type the first character of the search string. As you type in more characters, the search is refined.
  107. set incsearch
  108.  
  109. " wildmenu / wildmode -
  110. " http://stackoverflow.com/questions/9511253/how-to-effectively-use-vim-wildmenu
  111. set wildmenu
  112. set wildmode=longest:full,full
  113.  
  114. " Interpret .md files as markdown instead of modula2
  115. " More info - http://stackoverflow.com/a/14779012 and http://stackoverflow.com/a/23279293
  116. autocmd BufNewFile,BufFilePre,BufRead *.md set filetype=markdown
  117.  
  118.  
  119. set laststatus=2        " Set this to use (custom) statuslines.
  120.  
  121. """"""""""
  122. " airline
  123. """"""""""
  124. let g:airline_theme             = 'powerlineish'
  125. let g:airline#extensions#branch#enabled = 1
  126. let g:airline#extensions#syntastic#enabled = 0
  127. let g:airline#extensions#tabline#enabled = 1
  128.  
  129. "set timeoutlen=50 " https://github.com/bling/vim-airline/wiki/FAQ#there-is-a-pause-when-leaving-insert-mode
  130. " Tweak ttimeout because it messes with the time it takes to succesfully do a
  131. " keycombo.
  132. set ttimeout
  133. set ttimeoutlen=50
  134.  
  135. if !exists('g:airline_symbols')
  136.   let g:airline_symbols = {}
  137. endif
  138.  
  139. " unicode symbols
  140. let g:airline_left_sep = '»'
  141. let g:airline_left_sep = 'â–¶'
  142. let g:airline_right_sep = '«'
  143. let g:airline_right_sep = 'â—€'
  144. let g:airline_symbols.linenr = '␊'
  145. let g:airline_symbols.linenr = '␤'
  146. let g:airline_symbols.linenr = '¶'
  147. let g:airline_symbols.branch = '⎇'
  148. let g:airline_symbols.paste = 'ρ'
  149. let g:airline_symbols.paste = 'Þ'
  150. let g:airline_symbols.paste = '∥'
  151. let g:airline_symbols.whitespace = 'Ξ'
  152.  
  153. " variable names, see :help airline (airline-customization) for more info
  154. "let g:airline_section_a
  155. "let g:airline_section_b
  156. let g:airline_section_c = '%F'
  157. "let g:airline_section_gutter  
  158. "let g:airline_section_x      
  159. "let g:airline_section_y      
  160. "let g:airline_section_z      
  161. let g:airline_section_warning = '%{WordCount()} wds'
  162.  
  163. """"""""""""""""""""
  164.  
  165.  
  166. """"""""""""""""""
  167. " </ COSMETICS > "
  168. """"""""""""""""""
  169.  
  170.  
  171.  
  172. """ vim-lexical plugin
  173. """ https://github.com/reedes/vim-lexical
  174.  
  175. " Define which filetypes are going to get lexical applied.
  176. augroup lexical
  177.   autocmd!
  178.   autocmd FileType markdown,mkd call lexical#init()
  179.   autocmd FileType textile call lexical#init()
  180.   autocmd FileType text call lexical#init({ 'spell': 0 })
  181. augroup END
  182.  
  183. " Location to the thesaurus. Also for vim.
  184. " Online location is http://www.gutenberg.org/files/3202/ - but file is around ~25mb
  185. let g:lexical#thesaurus = ['~/.thesaurus/mthesaur.txt',]
  186. set thesaurus+=~/.thesaurus/mthesaur.txt
  187.  
  188.  
  189. " Uncomment the following to have Vim jump to the last position when
  190. " reopening a file
  191. if has("autocmd")
  192.   au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
  193. endif
  194.  
  195. " Uncomment the following to have Vim load indentation rules and plugins
  196. " according to the detected filetype.
  197. "if has("autocmd")
  198. "  filetype plugin indent on
  199. "endif
  200.  
  201. " Set tab to only have 4 columns.
  202. " http://tedlogan.com/techblog3.html
  203. set tabstop=4
  204.  
  205.  
  206. """ Custom Mappings
  207. " Set the leader in vim
  208. " http://usevim.com/2012/07/20/vim101-leader/
  209. let mapleader='\'
  210.  
  211. " Remap Ctrl+c to double Esc. Double because otherwise hitting C-c will wait the length of timeoutlen before executing.
  212. " More info - http://stackoverflow.com/a/80761
  213. inoremap <C-c> <Esc><Esc>
  214.  
  215. " Remap Ctrl-a and Ctrl-e in insert mode to move to line beginning and line to the end of the line respectively.
  216. " This coincides with *gasp* the Emacs mode in Bash readline, and I'm pretty used to that mapping.
  217. " See this SO post about it - http://stackoverflow.com/a/11487877
  218. " You do lose some features, but I don't think I'll be needing them at this moment.
  219. inoremap <C-e> <End>
  220. inoremap <C-a> <Home>
  221.  
  222. " The following are commented out as they cause vim to behave a lot
  223. " differently from regular Vi. They are highly recommended though.
  224. set showcmd             " Show (partial) command in status line.
  225. set showmatch           " Show matching brackets when text indicator is over them.
  226. set ignorecase          " Do case insensitive matching
  227. set smartcase           " Do smart case matching, make searches case-sensitive only if they contain upper-case characters.
  228. "set incsearch          " Incremental search
  229. "set autowrite          " Automatically save before commands like :next and :make
  230. "set hidden             " Hide buffers when they are abandoned
  231. "set mouse=a            " Enable mouse usage (all modes)
  232. set history=9001        " We gon way back...
  233.  
  234. " Source a global configuration file if available
  235. if filereadable("/etc/vim/vimrc.local")
  236.   source /etc/vim/vimrc.local
  237. endif
  238.  
  239. " Language-dependant autocompletion (otherwise known as Intellisense for Visual Studio)
  240. " Source - http://vim.wikia.com/wiki/Omni_completion
  241. " To use omni completion, type <C-X><C-O> while open in Insert mode. If matching names are found, a pop-up menu opens which can be navigated using the <C-N> and <C-P> keys.
  242. filetype plugin on
  243. set omnifunc=syntaxcomplete#Complete
  244.  
  245.  
  246. " Set this to get access to lots of tabs.
  247. set tabpagemax=20
  248.  
  249. " Tell vim not to add a newline on every (saved) file.
  250. " http://stackoverflow.com/questions/14171254/why-would-vim-add-a-new-line-at-the-end-of-a-file
  251. " set fileformats+=dos
  252. " But apparently there's no easy way to do this -_-

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at