From 383d1e08d05d17da983b726d175cfb5249ce2f5b Mon Sep 17 00:00:00 2001 From: Stefan Pranger Date: Wed, 28 Sep 2022 07:28:03 +0200 Subject: [PATCH] added presentation vimrc --- pres.vim | 303 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 303 insertions(+) create mode 100644 pres.vim diff --git a/pres.vim b/pres.vim new file mode 100644 index 0000000..7f2816f --- /dev/null +++ b/pres.vim @@ -0,0 +1,303 @@ +" presentation .vimrc from Sebastian Daschner https://www.youtube.com/watch?v=GDa7hrbcCB8 + +set encoding=utf-8 +set tabstop=2 +set shiftwidth=2 +set expandtab +set smarttab +set autoindent +set nowrap +set smartcase +set showmatch +set title +set ruler +set et +set number relativenumber +set incsearch +set hlsearch +set autoread +set autowrite +set nobackup +set nowritebackup +set noswapfile +set nocompatible +set backspace=indent,eol,start +" title required for i3 status checking, modified indicator at end +"set titlestring=%t%(\ \(%F\)%)%a\ -\ VIM%(\ %M%) +set titlestring=%(%F%)%a\ -\ VIM%(\ %M%) +set t_Co=16 +" undo cursorlinenr underline (was introduced Aug '19) +hi CursorLineNr cterm=bold + + + +" allows buffers to be hidden if you modified a buffer +set hidden +filetype off +syntax on + +set norelativenumber +set nonumber +set noshowmode +set noshowcmd +set nohidden +set noruler + +" removes possibility to define function keys that start with +" see if has implications +"set noesckeys + + +" Vundle +"<<<<<<<<<<<<<<<<<<<< +"set rtp+=~/.vim/bundle/Vundle.vim +"call vundle#begin() +" +"" let Vundle manage Vundle, required +"Plugin 'VundleVim/Vundle.vim' +" +"Plugin 'tpope/vim-surround' +"Plugin 'tpope/vim-repeat' +" +"" UltiSnips for completion / templating +"Plugin 'SirVer/ultisnips' +" +"" Snippets are separated from the engine. Add this if you want them: +"Plugin 'sdaschner/vim-snippets' +"Plugin 'ervandew/supertab' + +let g:SuperTabDefaultCompletionType = '' +let g:SuperTabCrMapping = 0 +let g:UltiSnipsExpandTrigger = '' +let g:UltiSnipsJumpForwardTrigger = '' +let g:UltiSnipsJumpBackwardTrigger = '' + + +" All of your Plugins must be added before the following line +" call vundle#end() +filetype plugin indent on + +" something messes up this setting in the plugins +set expandtab + + + +let mapleader = "," + +nmap O +nmap o + +inoremap +inoremap +inoremap +inoremap +noremap +noremap + +" presentation mode +noremap :silent bp :redraw! +noremap :silent bn :redraw! +nmap :set relativenumber! number! showmode! showcmd! hidden! ruler! +nmap :call DisplayPresentationBoundaries() +nmap :call FindExecuteCommand() + +" jump to slides +nmap :call JumpFirstBuffer() :redraw! +nmap :call JumpSecondToLastBuffer() :redraw! +nmap :call JumpLastBuffer() :redraw! + + +" move lines with Ctrl + (Shift) +J/K +nnoremap :m +1 +nnoremap :m -2 +inoremap :m +1gi +inoremap :m -2gi +vnoremap :m '>+1gvgv +vnoremap :m '<-2gvgv + +" opens a new empty buffer +nmap t :enew +" moves to the next buffer +nmap l :bnext +" moves to the previous buffer +nmap h :bprevious +" closes the current buffer, moves to the previous one +nmap bd :bd +" forces buffer close +nmap BD :bd! +" shows all open buffers and their status +nmap bl :ls +" toggles the paste mode +nmap :set paste! +" toggles word wrap +nmap :set wrap! linebreak +" toggles spell checking +nmap :set spell! spelllang=en_us +" opens the last buffer +nnoremap +" adds a line of < +nmap a :normal 20i< +" makes Ascii art font +nmap F :.!toilet --directory /usr/share/figlet -w 200 -f pagga +nmap f :.!toilet --directory /usr/share/figlet -w 200 -f futureijjI +" makes Ascii border +nmap 1 :.!toilet -w 200 -f term -F border + +" system clipboard +vmap y "+y +vmap d "+d +nmap y "+yy +nmap p "+p +nmap P "+P +vmap p "+p +vmap P "+P + +nmap d +nmap u +vmap d +vmap u + +" file operations +nmap :w +nmap :q + +let &t_ti.="\e[1 q" +let &t_SI.="\e[5 q" +let &t_EI.="\e[1 q" +let &t_te.="\e[0 q" + +" search highlighting color +highlight Search ctermfg=grey ctermbg=red + +" removes search highlighting +nnoremap :nohl + +" execute command +nmap !!zsh + +" AsciiDoc preview +nmap v :!asciidoc-view % + +" Transparent editing of gpg encrypted files. +" By Wouter Hanegraaff +augroup encrypted + au! + + " First make sure nothing is written to ~/.viminfo while editing + " an encrypted file. + autocmd BufReadPre,FileReadPre *.gpg set viminfo= + " We don't want a swap file, as it writes unencrypted data to disk + autocmd BufReadPre,FileReadPre *.gpg set noswapfile + + " Switch to binary mode to read the encrypted file + autocmd BufReadPre,FileReadPre *.gpg set bin + autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2 + " (If you use tcsh, you may need to alter this line.) + autocmd BufReadPost,FileReadPost *.gpg '[,']!gpg --decrypt 2> /dev/null + + " Switch to normal mode for editing + autocmd BufReadPost,FileReadPost *.gpg set nobin + autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save + autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r") + + " Convert all text to encrypted text before writing + " (If you use tcsh, you may need to alter this line.) + autocmd BufWritePre,FileWritePre *.gpg '[,']!gpg --default-recipient-self -ae 2>/dev/null + " Undo the encryption so we are back in the normal text, directly + " after the file has been written. + autocmd BufWritePost,FileWritePost *.gpg u +augroup END + +function! JumpFirstBuffer() + execute "buffer 1" +endfunction + +function! JumpSecondToLastBuffer() + execute "buffer " . (len(Buffers()) - 1) +endfunction + +function! JumpLastBuffer() + execute "buffer " . len(Buffers()) +endfunction + +function! Buffers() + let l:buffers = filter(range(1, bufnr('$')), 'bufexists(v:val)') + return l:buffers +endfunction + +" Automatically source an eponymous .vim or ..vim if it exists, as a bulked-up +" modeline and to provide file-specific customizations. +function! s:AutoSource() + let l:testedScripts = ['syntax.vim'] + if expand(':e') !=# 'vim' + " Don't source the edited Vimscript file itself. + call add(l:testedScripts, 'syntax.vim') + endif + + for l:filespec in l:testedScripts + if filereadable(l:filespec) + execute 'source' fnameescape(l:filespec) + endif + endfor + + call FindExecuteCommand() +endfunction +augroup AutoSource + autocmd! BufNewFile,BufRead * call AutoSource() +augroup END + + +set foldtext=SimpleFoldText() +set fillchars=fold:\ +function SimpleFoldText() + let line = getline(v:foldstart) + let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g') + return sub . ' >>>>>>' +endfunction + +set foldlevelstart=20 +set foldmethod=expr +set foldexpr=ListFolds() + +function! ListFolds() + let thisline = getline(v:lnum) + if match(thisline, '^- ') >= 0 + return ">1" + elseif match(thisline, '^ - ') >= 0 + return ">2" + elseif match(thisline, '^ - ') >= 0 + return ">3" + elseif match(thisline, '^ - ') >= 0 + return ">4" + elseif match(thisline, '^ - ') >= 0 + return ">5" + endif + return "0" +endfunction + + +let g:presentationBoundsDisplayed = 0 +function! DisplayPresentationBoundaries() + if g:presentationBoundsDisplayed + match + set colorcolumn=0 + let g:presentationBoundsDisplayed = 0 + else + highlight lastoflines ctermbg=darkred + highlight topicborder ctermbg=darkblue + match lastoflines /\%23l/ + match topicborder /\%9l/ + set colorcolumn=13,80 + let g:presentationBoundsDisplayed = 1 + endif +endfunction + +function! FindExecuteCommand() + let line = search('\S*!'.'!:.*') + if line > 0 + let command = substitute(getline(line), "\S*!"."!:*", "", "") + execute "silent !". command + execute "normal gg0" + redraw + endif +endfunction