Guest User

Untitled

a guest
Oct 22nd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.93 KB | None | 0 0
  1. "====[ Make the 81st column stand out ]====================
  2.  
  3. " EITHER the entire 81st column, full-screen...
  4. highlight ColorColumn ctermbg=magenta
  5. set colorcolumn=81
  6.  
  7. " OR ELSE just the 81st column of wide lines...
  8. highlight ColorColumn ctermbg=magenta
  9. call matchadd('ColorColumn', '\%81v', 100)
  10.  
  11. " OR ELSE on April Fools day...
  12. highlight ColorColumn ctermbg=red ctermfg=blue
  13. exec 'set colorcolumn=' . join(range(2,80,3), ',')
  14.  
  15.  
  16. "=====[ Highlight matches when jumping to next ]=============
  17.  
  18. " This rewires n and N to do the highlighing...
  19. nnoremap <silent> n n:call HLNext(0.4)<cr>
  20. nnoremap <silent> N N:call HLNext(0.4)<cr>
  21.  
  22.  
  23. " EITHER blink the line containing the match...
  24. function! HLNext (blinktime)
  25. set invcursorline
  26. redraw
  27. exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
  28. set invcursorline
  29. redraw
  30. endfunction
  31.  
  32. " OR ELSE ring the match in red...
  33. function! HLNext (blinktime)
  34. highlight RedOnRed ctermfg=red ctermbg=red
  35. let [bufnum, lnum, col, off] = getpos('.')
  36. let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
  37. echo matchlen
  38. let ring_pat = (lnum > 1 ? '\%'.(lnum-1).'l\%>'.max([col-4,1]) .'v\%<'.(col+matchlen+3).'v.\|' : '')
  39. \ . '\%'.lnum.'l\%>'.max([col-4,1]) .'v\%<'.col.'v.'
  40. \ . '\|'
  41. \ . '\%'.lnum.'l\%>'.max([col+matchlen-1,1]) .'v\%<'.(col+matchlen+3).'v.'
  42. \ . '\|'
  43. \ . '\%'.(lnum+1).'l\%>'.max([col-4,1]) .'v\%<'.(col+matchlen+3).'v.'
  44. let ring = matchadd('RedOnRed', ring_pat, 101)
  45. redraw
  46. exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
  47. call matchdelete(ring)
  48. redraw
  49. endfunction
  50.  
  51. " OR ELSE briefly hide everything except the match...
  52. function! HLNext (blinktime)
  53. highlight BlackOnBlack ctermfg=black ctermbg=black
  54. let [bufnum, lnum, col, off] = getpos('.')
  55. let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
  56. let hide_pat = '\%<'.lnum.'l.'
  57. \ . '\|'
  58. \ . '\%'.lnum.'l\%<'.col.'v.'
  59. \ . '\|'
  60. \ . '\%'.lnum.'l\%>'.(col+matchlen-1).'v.'
  61. \ . '\|'
  62. \ . '\%>'.lnum.'l.'
  63. let ring = matchadd('BlackOnBlack', hide_pat, 101)
  64. redraw
  65. exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
  66. call matchdelete(ring)
  67. redraw
  68. endfunction
  69.  
  70. " OR ELSE just highlight the match in red...
  71. function! HLNext (blinktime)
  72. let [bufnum, lnum, col, off] = getpos('.')
  73. let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/))
  74. let target_pat = '\c\%#\%('.@/.'\)'
  75. let ring = matchadd('WhiteOnRed', target_pat, 101)
  76. redraw
  77. exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
  78. call matchdelete(ring)
  79. redraw
  80. endfunction
  81.  
  82.  
  83. "====[ Make tabs, trailing whitespace, and non-breaking spaces visible ]======
  84.  
  85. exec "set listchars=tab:\uBB\uBB,trail:\uB7,nbsp:~"
  86. set list
  87.  
  88.  
  89. "====[ Swap : and ; to make colon commands easier to type ]======
  90.  
  91. nnoremap ; :
  92. nnoremap : ;
  93.  
  94.  
  95. "====[ Swap v and CTRL-V, because Block mode is more useful that Visual mode "]======
  96.  
  97. nnoremap v <C-V>
  98. nnoremap <C-V> v
  99.  
  100. vnoremap v <C-V>
  101. vnoremap <C-V> v
  102.  
  103.  
  104. "====[ Always turn on syntax highlighting for diffs ]=========================
  105.  
  106. " EITHER select by the file-suffix directly...
  107. augroup PatchDiffHighlight
  108. autocmd!
  109. autocmd BufEnter *.patch,*.rej,*.diff syntax enable
  110. augroup END
  111.  
  112. " OR ELSE use the filetype mechanism to select automatically...
  113. filetype on
  114. augroup PatchDiffHighlight
  115. autocmd!
  116. autocmd FileType diff syntax enable
  117. augroup END
  118.  
  119.  
  120. "====[ Open any file with a pre-existing swapfile in readonly mode "]=========
  121.  
  122. augroup NoSimultaneousEdits
  123. autocmd!
  124. autocmd SwapExists * let v:swapchoice = 'o'
  125. autocmd SwapExists * echomsg ErrorMsg
  126. autocmd SwapExists * echo 'Duplicate edit session (readonly)'
  127. autocmd SwapExists * echohl None
  128. autocmd SwapExists * sleep 2
  129. augroup END
  130.  
  131. " Also consider the autoswap_mac.vim plugin (but beware its limitations)
  132.  
  133.  
  134. "====[ Mappings to activate spell-checking alternatives ]================
  135.  
  136. nmap ;s :set invspell spelllang=en<CR>
  137. nmap ;ss :set spell spelllang=en-basic<CR>
  138.  
  139. " To create the en-basic (or any other new) spelling list:
  140. "
  141. " :mkspell ~/.vim/spell/en-basic basic_english_words.txt
  142. "
  143. " See :help mkspell
  144.  
  145.  
  146. "====[ Make CTRL-K list diagraphs before each digraph entry ]===============
  147.  
  148. inoremap <expr> <C-K> ShowDigraphs()
  149.  
  150. function! ShowDigraphs ()
  151. digraphs
  152. call getchar()
  153. return "\<C-K>"
  154. endfunction
  155.  
  156. " But also consider the hudigraphs.vim and betterdigraphs.vim plugins,
  157. " which offer smarter and less intrusive alternatives
Add Comment
Please, Sign In to add comment