Skip to content

Instantly share code, notes, and snippets.

@davidmh
Last active August 3, 2020 13:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidmh/f4337f9ea9eca6789b3f8222b8333a35 to your computer and use it in GitHub Desktop.
Save davidmh/f4337f9ea9eca6789b3f8222b8333a35 to your computer and use it in GitHub Desktop.
Presentation mode with Goyo + vim-markdown
" https://asciinema.org/a/kE1398clJWRPPhk3lWbtvbanF
" Presentation mode
"
" use <left> and <right> to navigate the slides
"
" https://github.com/plasticboy/vim-markdown Makes folds by sections (among many other things)
" https://github.com/junegunn/goyo.vim Distraction-free writing (and reading) in Vim
function! s:enter_presentation()
" increase conceal level
set conceallevel=3
" open first fold
normal ggzo
" add navigation
" C-n next slide
" zc - close current fold
" zj - move to the next
" zo - and open it
" [z - move to the start of the current fold
" j - move the cursor out of the way
nnoremap <buffer> <right> zczjzo[z<esc>j
" C-p previous slide
" zc - close current fold
" zk - move to the previous
" zo - and open it
" [z - move to the start of the current fold
" j - move the cursor out of the way
nnoremap <buffer> <left> zczkzo[zj
endfunction
function! s:exit_presentation()
" reset conceal level
set conceallevel=0
nunmap <buffer> <left>
nunmap <buffer> <right>
endfunction
autocmd! User GoyoEnter nested call <SID>enter_presentation()
autocmd! User GoyoLeave nested call <SID>exit_presentation()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment