Advertisement
alaestor

[VIM] .vimrc

Oct 8th, 2017
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 4.38 KB | None | 0 0
  1. source $VIMRUNTIME/mswin.vim
  2. behave mswin
  3.  
  4. " In keeping with FGL standards, this vimrc favors tabs over spaces
  5. " Alaestor's _vimrc file (2017 FGL)
  6.  
  7. "CUSTOM KEY MAPS
  8. " Esc remove search highlighting
  9. " < indent {} block to the left at cursor
  10. " > indent {} block to the right at cursor
  11. " <leader>[ folds file entirely, and opens one level.
  12. " <leader>] expands all folds
  13. " <leader><backspace> removes trailing whitespace
  14. " <leader>= reindent file and remove trailing whitespace
  15. " <leader><right> reddit conversion: add 4 spaces infront of everything
  16. " <leader><left> reddit conversion: remove 4 spaces infront of every line
  17. " F2 toggle error highlighting
  18. " F3 toggle viewing whitespace characters
  19. " F4 toggle line wrapping (by word)
  20. " F5 identify syntax highlighting group at cursor
  21.  
  22. "TROLL REMAPS
  23. " <leader>~ replace newlines with spaces, remove redundant whitespace
  24. " <leader>` put a space before every newline
  25.  
  26.  
  27. set nocompatible
  28. syntax on
  29. filetype plugin on
  30. filetype indent on
  31.  
  32.  
  33. "file finding (':find *.cpp' and ':b ' for buffers)
  34. set path+=** "recursive
  35. set wildmenu
  36. set ignorecase
  37. set smartcase
  38.  
  39.  
  40. "folding
  41. set mouse=a
  42. set foldcolumn=1
  43. set foldlevelstart=1 "start folded
  44. set foldnestmax=10
  45. set foldmethod=syntax "indent or manual or syntax
  46.  
  47.  
  48. "editor layout
  49. set visualbell t_vb=
  50. au GuiEnter * set visualbell t_vb=
  51. set laststatus=2
  52. set number
  53. set numberwidth=5
  54. set lazyredraw
  55. set ruler
  56. set nowrap
  57.  
  58.  
  59. "control
  60. set backspace=indent,eol,start
  61. set sc
  62.  
  63.  
  64. "matching pairs
  65. set matchpairs+=(:)
  66. set matchpairs+={:}
  67. set matchpairs+=<:>
  68.  
  69.  
  70. "whitespace characters
  71. set shiftwidth=4
  72. set tabstop=4
  73.     "indenting style... I love cindent!!!
  74.     "issue: templates. +0 no indent for incomplete line. fixes, but not optimal.
  75. set cindent
  76. set cinoptions=h0,:0,=s,l1,cs,C1,(s,)50,*300,U1,Ws,m1,N-s,+0
  77.     "disable automatic comment-insertion when you newline
  78. autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
  79. set listchars=tab:>-,trail:¬,extends:>,precedes:<,eol:»,nbsp:#,space:·
  80. "set list to default on
  81.     "keybind
  82. nnoremap <F3> :set invlist<CR>
  83.  
  84.  
  85. "highlighting
  86. colorscheme FGL_custom
  87. "   errors
  88. set hlsearch
  89. let s:ehl = 0
  90. function! ToggleEH()
  91.     if s:ehl == 0
  92.         let s:ehl = 1
  93.         let w:hlWidthLimit = matchadd("ErrorMsg",'\%>79v.\+',-1)
  94.         let w:hlRedundant = matchadd("ErrorMsg",'\(\s\+$\| \+\ze\t\|\t\zs \+\)\(\%#\)\@!',-1)
  95.         let w:hlDoubleSpace = matchadd("ErrorMsg",' \{2,}',-1)
  96.     else
  97.         let s:ehl = 0
  98.         call matchdelete(w:hlWidthLimit)
  99.         call matchdelete(w:hlRedundant)
  100.         call matchdelete(w:hlDoubleSpace)
  101.     endif
  102. endfunction
  103. call ToggleEH() " to default on
  104.     "keybind
  105. nnoremap <F2> :call ToggleEH()<CR>
  106. " line wrapping (by word)
  107. nnoremap <F4> :set wrap!<CR>:set lbr!<CR>
  108. " identify syntax highlighting group at cursor
  109. nnoremap <F5> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
  110.  
  111.  
  112. "keymapping utility
  113.     "unhighlight search terms
  114. nnoremap <Esc> :noh<CR><Esc>
  115.     "easily indent {} blocks from normal mode at cursor
  116. nnoremap < <Esc>viB<
  117. nnoremap > <Esc>viB>
  118.     "fold and expand
  119. nnoremap <leader>[ zMzr
  120. nnoremap <leader>] zR
  121.     "remove trailing whitespace
  122. nmap <leader><Backspace> :%s/\s\+$//e<CR>:%s/\ \ /\ /e<CR>
  123.     "reformat indent and remove trailing whitespace
  124. nnoremap <leader>= mzgg=G:%s/\s\+$//e<CR>:%s/\ \ /\ /e<CR>:noh<CR><Esc>`z
  125.     "reddit conversion: add 4 spaces infront of everything
  126. nnoremap <leader><right> :%s/^/    /e<CR>
  127.     "reddit conversion: remove 4 spaces infront of every line
  128. nnoremap <leader><left> :%s/^    //e<CR>
  129.     "trolly: replace newlines with spaces, remove redundant whitespace
  130. nnoremap <leader>~ :%s/\n/\ /<CR>:%s/\s\+\s/\ /<CR>:noh<CR><Esc>
  131.     "trolly: put a space before every newline
  132. nnoremap <leader>` :%s/$/\ /e<CR>:noh<CR><Esc>
  133.  
  134.  
  135. "loose file definitions
  136.     "backup files
  137. set backup "nobackup
  138. set writebackup "nowritebackup
  139. set backupdir=%TMP%//
  140.     "swap file
  141. set swapfile "noswapfile
  142. set directory=%TMP%//
  143.     "undo file
  144. set undofile "noundofile
  145. set undolevels=500 "1000
  146. set undoreload=5000 "10000
  147. set undodir=%TMP%//
  148.  
  149. "useful links
  150. "https://youtu.be/XA2WjJbmmoM 'How to Do 90% of What Plugins Do'
  151. "http://vim.wikia.com/wiki/Vim_Tips_Wiki
  152. "http://vimdoc.sourceforge.net/htmldoc/indent.html#cinoptions-values
  153. "http://vimdoc.sourceforge.net/htmldoc/indent.html#cinkeys-format
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement