You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

303 lines
7.7 KiB

  1. " presentation .vimrc from Sebastian Daschner https://www.youtube.com/watch?v=GDa7hrbcCB8
  2. set encoding=utf-8
  3. set tabstop=2
  4. set shiftwidth=2
  5. set expandtab
  6. set smarttab
  7. set autoindent
  8. set nowrap
  9. set smartcase
  10. set showmatch
  11. set title
  12. set ruler
  13. set et
  14. set number relativenumber
  15. set incsearch
  16. set hlsearch
  17. set autoread
  18. set autowrite
  19. set nobackup
  20. set nowritebackup
  21. set noswapfile
  22. set nocompatible
  23. set backspace=indent,eol,start
  24. " title required for i3 status checking, modified indicator at end
  25. "set titlestring=%t%(\ \(%F\)%)%a\ -\ VIM%(\ %M%)
  26. set titlestring=%(%F%)%a\ -\ VIM%(\ %M%)
  27. set t_Co=16
  28. " undo cursorlinenr underline (was introduced Aug '19)
  29. hi CursorLineNr cterm=bold
  30. " allows buffers to be hidden if you modified a buffer
  31. set hidden
  32. filetype off
  33. syntax on
  34. set norelativenumber
  35. set nonumber
  36. set noshowmode
  37. set noshowcmd
  38. set nohidden
  39. set noruler
  40. " removes possibility to define function keys that start with <Esc>
  41. " see if has implications
  42. "set noesckeys
  43. " Vundle
  44. "<<<<<<<<<<<<<<<<<<<<
  45. "set rtp+=~/.vim/bundle/Vundle.vim
  46. "call vundle#begin()
  47. "
  48. "" let Vundle manage Vundle, required
  49. "Plugin 'VundleVim/Vundle.vim'
  50. "
  51. "Plugin 'tpope/vim-surround'
  52. "Plugin 'tpope/vim-repeat'
  53. "
  54. "" UltiSnips for completion / templating
  55. "Plugin 'SirVer/ultisnips'
  56. "
  57. "" Snippets are separated from the engine. Add this if you want them:
  58. "Plugin 'sdaschner/vim-snippets'
  59. "Plugin 'ervandew/supertab'
  60. let g:SuperTabDefaultCompletionType = '<C-n>'
  61. let g:SuperTabCrMapping = 0
  62. let g:UltiSnipsExpandTrigger = '<tab>'
  63. let g:UltiSnipsJumpForwardTrigger = '<tab>'
  64. let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
  65. " All of your Plugins must be added before the following line
  66. " call vundle#end()
  67. filetype plugin indent on
  68. " something messes up this setting in the plugins
  69. set expandtab
  70. let mapleader = ","
  71. nmap <S-Enter> O<Esc>
  72. nmap <CR> o<Esc>
  73. inoremap <Up> <NOP>
  74. inoremap <Down> <NOP>
  75. inoremap <Left> <NOP>
  76. inoremap <Right> <NOP>
  77. noremap <Up> <NOP>
  78. noremap <Down> <NOP>
  79. " presentation mode
  80. noremap <Left> :silent bp<CR> :redraw!<CR>
  81. noremap <Right> :silent bn<CR> :redraw!<CR>
  82. nmap <F5> :set relativenumber! number! showmode! showcmd! hidden! ruler!<CR>
  83. nmap <F2> :call DisplayPresentationBoundaries()<CR>
  84. nmap <F3> :call FindExecuteCommand()<CR>
  85. " jump to slides
  86. nmap <F9> :call JumpFirstBuffer()<CR> :redraw!<CR>
  87. nmap <F10> :call JumpSecondToLastBuffer()<CR> :redraw!<CR>
  88. nmap <F11> :call JumpLastBuffer()<CR> :redraw!<CR>
  89. " move lines with Ctrl + (Shift) +J/K
  90. nnoremap <C-j> :m +1<CR>
  91. nnoremap <C-k> :m -2<CR>
  92. inoremap <C-j> <Esc>:m +1<CR>gi
  93. inoremap <C-k> <Esc>:m -2<CR>gi
  94. vnoremap <C-j> :m '>+1<CR>gvgv
  95. vnoremap <C-k> :m '<-2<CR>gvgv
  96. " opens a new empty buffer
  97. nmap <leader>t :enew<CR>
  98. " moves to the next buffer
  99. nmap <leader>l :bnext<CR>
  100. " moves to the previous buffer
  101. nmap <leader>h :bprevious<CR>
  102. " closes the current buffer, moves to the previous one
  103. nmap <leader>bd :bd<CR>
  104. " forces buffer close
  105. nmap <leader>BD :bd!<CR>
  106. " shows all open buffers and their status
  107. nmap <leader>bl :ls<CR>
  108. " toggles the paste mode
  109. nmap <C-p> :set paste!<CR>
  110. " toggles word wrap
  111. nmap <C-w> :set wrap! linebreak<CR>
  112. " toggles spell checking
  113. nmap <C-]> :set spell! spelllang=en_us<CR>
  114. " opens the last buffer
  115. nnoremap <leader><leader> <C-^>
  116. " adds a line of <
  117. nmap <leader>a :normal 20i<<CR>
  118. " makes Ascii art font
  119. nmap <leader>F :.!toilet --directory /usr/share/figlet -w 200 -f pagga<CR>
  120. nmap <leader>f :.!toilet --directory /usr/share/figlet -w 200 -f future<CR>i<CR><CR><CR><ESC><C-v>jjI<tab><tab><tab><tab><tab><tab><tab><ESC>
  121. " makes Ascii border
  122. nmap <leader>1 :.!toilet -w 200 -f term -F border<CR>
  123. " system clipboard
  124. vmap <leader>y "+y
  125. vmap <leader>d "+d
  126. nmap <leader>y "+yy
  127. nmap <leader>p "+p
  128. nmap <leader>P "+P
  129. vmap <leader>p "+p
  130. vmap <leader>P "+P
  131. nmap <leader>d <C-d>
  132. nmap <leader>u <C-u>
  133. vmap <leader>d <C-d>
  134. vmap <leader>u <C-u>
  135. " file operations
  136. nmap <C-s> :w<CR>
  137. nmap <C-q> :q<CR>
  138. let &t_ti.="\e[1 q"
  139. let &t_SI.="\e[5 q"
  140. let &t_EI.="\e[1 q"
  141. let &t_te.="\e[0 q"
  142. " search highlighting color
  143. highlight Search ctermfg=grey ctermbg=red
  144. " removes search highlighting
  145. nnoremap <silent> <C-l> :nohl<CR><C-l>
  146. " execute command
  147. nmap <leader><Enter> !!zsh<CR>
  148. " AsciiDoc preview
  149. nmap <leader>v :!asciidoc-view %<CR><CR>
  150. " Transparent editing of gpg encrypted files.
  151. " By Wouter Hanegraaff
  152. augroup encrypted
  153. au!
  154. " First make sure nothing is written to ~/.viminfo while editing
  155. " an encrypted file.
  156. autocmd BufReadPre,FileReadPre *.gpg set viminfo=
  157. " We don't want a swap file, as it writes unencrypted data to disk
  158. autocmd BufReadPre,FileReadPre *.gpg set noswapfile
  159. " Switch to binary mode to read the encrypted file
  160. autocmd BufReadPre,FileReadPre *.gpg set bin
  161. autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2
  162. " (If you use tcsh, you may need to alter this line.)
  163. autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null
  164. " Switch to normal mode for editing
  165. autocmd BufReadPost,FileReadPost *.gpg set nobin
  166. autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save
  167. autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r")
  168. " Convert all text to encrypted text before writing
  169. " (If you use tcsh, you may need to alter this line.)
  170. autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-recipient-self -ae 2>/dev/null
  171. " Undo the encryption so we are back in the normal text, directly
  172. " after the file has been written.
  173. autocmd BufWritePost,FileWritePost *.gpg u
  174. augroup END
  175. function! JumpFirstBuffer()
  176. execute "buffer 1"
  177. endfunction
  178. function! JumpSecondToLastBuffer()
  179. execute "buffer " . (len(Buffers()) - 1)
  180. endfunction
  181. function! JumpLastBuffer()
  182. execute "buffer " . len(Buffers())
  183. endfunction
  184. function! Buffers()
  185. let l:buffers = filter(range(1, bufnr('$')), 'bufexists(v:val)')
  186. return l:buffers
  187. endfunction
  188. " Automatically source an eponymous <file>.vim or <file>.<ext>.vim if it exists, as a bulked-up
  189. " modeline and to provide file-specific customizations.
  190. function! s:AutoSource()
  191. let l:testedScripts = ['syntax.vim']
  192. if expand('<afile>:e') !=# 'vim'
  193. " Don't source the edited Vimscript file itself.
  194. call add(l:testedScripts, 'syntax.vim')
  195. endif
  196. for l:filespec in l:testedScripts
  197. if filereadable(l:filespec)
  198. execute 'source' fnameescape(l:filespec)
  199. endif
  200. endfor
  201. call FindExecuteCommand()
  202. endfunction
  203. augroup AutoSource
  204. autocmd! BufNewFile,BufRead * call <SID>AutoSource()
  205. augroup END
  206. set foldtext=SimpleFoldText()
  207. set fillchars=fold:\
  208. function SimpleFoldText()
  209. let line = getline(v:foldstart)
  210. let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')
  211. return sub . ' >>>>>>'
  212. endfunction
  213. set foldlevelstart=20
  214. set foldmethod=expr
  215. set foldexpr=ListFolds()
  216. function! ListFolds()
  217. let thisline = getline(v:lnum)
  218. if match(thisline, '^- ') >= 0
  219. return ">1"
  220. elseif match(thisline, '^ - ') >= 0
  221. return ">2"
  222. elseif match(thisline, '^ - ') >= 0
  223. return ">3"
  224. elseif match(thisline, '^ - ') >= 0
  225. return ">4"
  226. elseif match(thisline, '^ - ') >= 0
  227. return ">5"
  228. endif
  229. return "0"
  230. endfunction
  231. let g:presentationBoundsDisplayed = 0
  232. function! DisplayPresentationBoundaries()
  233. if g:presentationBoundsDisplayed
  234. match
  235. set colorcolumn=0
  236. let g:presentationBoundsDisplayed = 0
  237. else
  238. highlight lastoflines ctermbg=darkred
  239. highlight topicborder ctermbg=darkblue
  240. match lastoflines /\%23l/
  241. match topicborder /\%9l/
  242. set colorcolumn=13,80
  243. let g:presentationBoundsDisplayed = 1
  244. endif
  245. endfunction
  246. function! FindExecuteCommand()
  247. let line = search('\S*!'.'!:.*')
  248. if line > 0
  249. let command = substitute(getline(line), "\S*!"."!:*", "", "")
  250. execute "silent !". command
  251. execute "normal gg0"
  252. redraw
  253. endif
  254. endfunction