Advertisement
AfroNinja

vimrc file

Dec 29th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 4.50 KB | None | 0 0
  1. " ============================================================================
  2. " VIMRC file
  3. " --------------------------------------------------
  4. " Developed while learning Vimscript
  5. " at HTTP://learnvimscriptthehardway.stevelosh.com
  6. " ============================================================================
  7.  
  8. " ============================================================================
  9. " GLOBAL OPTIONS
  10. " ============================================================================
  11. " {{{
  12.  
  13. " -----------------------------
  14. " ensure Vim settings are used
  15. " -----------------------------
  16. set nocompatible
  17.  
  18. " ---------------------------
  19. " Map Leader and Local Leader
  20. " ---------------------------
  21. let mapleader = '-'
  22. let maplocalleader = '\\'
  23.  
  24. " ------------
  25. " Code folding
  26. " ------------
  27. augroup filetype_vim
  28.     autocmd!
  29.     autocmd FileType vim setlocal foldmethod=marker
  30.     autocmd FileType vim :normal! zM
  31. augroup end
  32.  
  33. " }}}
  34. " ============================================================================
  35. " FORMATTING OPTIONS
  36. " ============================================================================
  37. " {{{
  38.  
  39. " ---------------------
  40. " Colors and formatting
  41. " ---------------------
  42. colorscheme badwolf
  43. "-- ensure background consistency
  44. "-- when scrolling in a terminal
  45. set t_ut=
  46.  
  47. " ------------------
  48. " Set line numbering
  49. " ------------------
  50. set number numberwidth=4
  51. set relativenumber
  52.  
  53. " -----------------------
  54. " Line-control mechanisms
  55. " -----------------------
  56. set nowrap
  57.  
  58. " ---------------------
  59. " Tab stops and spacing
  60. " ---------------------
  61. set tabstop=4
  62. set softtabstop=4
  63. set shiftwidth=4
  64. set expandtab
  65.  
  66. " }}}
  67. " ============================================================================
  68. " MAPPINGS AND COMMANDS
  69. " ============================================================================
  70. " {{{
  71.  
  72. " -------------------
  73. " Custom key mappings
  74. " -------------------
  75.  
  76. " -- normal mode mappings
  77. " -----------------------
  78. " {{{
  79. " - word at cursor position to uppercase
  80. nnoremap <leader>u viwU
  81.  
  82. " - quick configuration file editing
  83. nnoremap <leader>ev :vsplit $MYVIMRC<cr>
  84. nnoremap <leader>sv :source $MYVIMRC<cr>:echo $MYVIMRC "sourced"<cr>
  85.  
  86. " - shortcut to toggle highlighting after a search
  87. nnoremap <leader>hh :set hlsearch!<cr>
  88.  
  89. " - highlight trailing white space and line end
  90. "   with Error color pattern
  91. nnoremap <leader>w :match Error /\v\s+$/<cr>
  92.  
  93. " - open or close quick fix window
  94. " {{{
  95. nnoremap <leader>q :call QuickfixToggle()<cr>
  96.  
  97. " -- set variable and close quick fix window
  98. let g:quickfix_is_open = 0
  99. cclose
  100.  
  101. " -- quick fix toggle function
  102. function! QuickfixToggle()
  103.     if g:quickfix_is_open
  104.         cclose
  105.         let g:quickfix_is_open = 0
  106.         execute g:quickfix_return_to_window . "wincmd w"
  107.     else
  108.         let g:quickfix_return_to_window = winnr()
  109.         copen
  110.         let g:quickfix_is_open = 1
  111.     endif
  112. endfunction
  113. " }}}
  114.  
  115. " - move to next and previous results in quick fix window
  116. nnoremap cn :cnext<cr>
  117. nnoremap cp :cprevious<cr>
  118.  
  119. " - toggle cursor line highlighting
  120. " -- cursor line highlighting
  121. nnoremap <leader>cl :set cursorline!<cr>
  122.  
  123. " }}}
  124.  
  125. " -- visual mode mappings
  126. " -----------------------
  127. " {{{
  128.  
  129.  
  130. " }}}
  131.  
  132. " -- insert mode mappings
  133. " -----------------------
  134. " {{{
  135. " }}}
  136.  
  137. " -------------
  138. " Abbreviations
  139. " -------------
  140.  
  141. " }}}
  142. " ============================================================================
  143. " OTHER CONFIGURATION OPTIONS
  144. " ============================================================================
  145. " {{{
  146.  
  147. " ------------------
  148. " Enable visual menu
  149. " ------------------
  150. set wildmenu
  151.  
  152. " --------------------
  153. " Show matching [{()}]
  154. " --------------------
  155. set showmatch
  156.  
  157. " ------------
  158. " Code folding
  159. " ------------
  160. set foldenable
  161. set foldlevelstart=10
  162. set foldnestmax=10
  163. set foldmethod=indent
  164.  
  165. " --------------
  166. " Syntax options
  167. " --------------
  168.  
  169. " -- highlighting on
  170. syntax enable
  171.  
  172. " -- filetype indent on
  173. filetype indent on
  174.  
  175. " --------------
  176. " Search options
  177. " --------------
  178. " -- highlight search
  179. set hlsearch
  180. " -- incremental search
  181. set incsearch
  182.  
  183. " --------------
  184. " Spell checking
  185. " --------------
  186. set spell spelllang=en_us
  187.  
  188. " ----------------
  189. " show status line
  190. " ----------------
  191. set laststatus=2
  192.  
  193. " ---------------------
  194. " customize status line
  195. " ---------------------
  196. set statusline =%-30.30t
  197. set statusline+=%#StatusLineNC#
  198. set statusline+=\ %y\ %r
  199. set statusline+=%=
  200. set statusline+=%m
  201. set statusline+=\ %c,%l
  202. set statusline+=\ [%L]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement