3

I came across this video about Vim. I would like to ask how can you create a presentation like in the video which seems to run inside Vim.

On some slides there are also real pictures displayed. Check 7:25 and 25:20 of the video.

https://www.youtube.com/watch?v=MquaityA1SM

Anyone knows how this is done?

Thanks!

3
  • Not so sure that is inside Vim...but I'm interested to know for sure.
    – Wildcard
    Commented Nov 1, 2015 at 5:52
  • For a moment, I thought I was missing something. The slides are probably HTML pages styled to look like Vim. Around 12:53, he was using Vim for demo, then quit using :x to go back to the presentation. Thanks for your replies!
    – yinyangero
    Commented Nov 1, 2015 at 15:14
  • Maybe Emacs can do it? ;)
    – Alexey
    Commented Nov 18, 2015 at 5:48

4 Answers 4

2

I was watching that video yesterday and had basically the same question.
As Wildcard already pointed out, I am pretty sure that the images are not directly displayed in Vim.

What I did for my current presentation is just a little bash script that opens all markdown files (*.md) in a separate tab. The script also changes my vimrc to one with a light background.

vim -u ~/.vimrc-light -p *.md

There is also git-slides or vimdeck that both look very promising, but did not work for me particularly well.

2
  • +1 for git-slides, which seems very useful
    – mMontu
    Commented Nov 4, 2015 at 11:51
  • mdp doesn't do images like the OP is asking about but I've used it many times for presentations.
    – gabe
    Commented Apr 11, 2020 at 22:37
2

That presentation is just a pdf. You can find the link at the bottom of most slides.

1

In order to get real pictures in vim you have to get a terminal emulator that can show images. I don't know linux options, but for macOS, ITerm2 does it perfectly. ITerms2 has a special escape sequence that can be used by any terminal app to tell the emulator to print an image.

So you could program an autocommand that tells vim to run a command (imgcat for ITerms2) when it opens a .png .gif or .svg and to kill the buffer (so the binary code of the image does not open). This one does the job :

autocmd BufEnter *.png,*.jpg,*gif,*.svg exec "! ~/.iterm2/imgcat ".expand("%") | :bw

Another option is to open it with another app. For example, you could create your own extetion, like .vpng (vim png), and tell vim to read its contents (that would be the address of the image) and to pass it to a command. Example : your slide10.vpng file would contain path/to/my_image.png and then, when vim opens the file, it runs open [file contents], so here : open path/to/my_image.png. I don't know the linux command to run, but both solutions worked for me.

1

For presentations I found few useful plugins (not mandatory, but very useful) and options.

Plugins

Goyo - distraction free

The plugin Goyo, that removes all the visual elements (line numbering, status bar, tabs...) to make kind of like the VSCode "zen mode". Cool for presentations (I assume you don't want these elements).

Vim markdown - markdown right in vim

The plugin vim-markdown, that shows pretty markdown, like in emacs org-mode (the surrounding * or _ are removed when your cursor is not on the line). I use it with the g:vim_markdown_math set to 1 to I have kink of a LaTeX equation preview.

Configurations

shortcuts

I use the .vpm extension for my presentations. The idea is to make a file named 000.vpm, and a 001.vpm, then 002.vpm etc. so vim will open them in the right order. Then I open them all with vim *.vpm.

" when a .vpm file is opened, set the shortcuts
autocmd BufNewFile,BufRead *.vpm call SetVimPresentationMode()
function SetVimPresentationMode()
    " proper filetype for vim-markdown
    set ft=markdown

    " <buffer> so other filetypes aren't affected even if you open them in your presentation
    " silent so if you try to go after the last or before the first slide, you do not get any error (nothing happens)
    nnoremap <buffer> <space> :silent n<cr>
    nnoremap <buffer> <up> :silent N<cr>
    nnoremap <buffer> <down> :silent n<cr>
    nnoremap <left> :silent N<cr>
    nnoremap <right> :silent n<cr>


    if !exists("#goyo")
        " start Goyo
        Goyo 130
    endif
endfunction

Then, you can add some special highlighting for titles etc. if you don't like the basic ones for markdown. Here en example (just putted simple colours) :

" with .vpm files : load proper highlighting
autocmd BufWinEnter *.vpm call VimPresentationColors()
function VimPresentationColors()
    " hide dashes (they are annoying if you don't know markdown)
    " you could do a conceal so they don't have any indentation difference  
    syn match dashes "^#\+"
    hi dashes ctermfg=black

    " here are the simple colours :
    hi htmlH1 cterm=bold ctermbg=214 ctermfg=16
    hi htmlH2 cterm=bold ctermbg=69 ctermfg=16
    hi htmlH3 cterm=bold ctermbg=34 ctermfg=16
    hi htmlH4 cterm=bold ctermbg=16 ctermfg=214
    hi htmlH5 cterm=bold ctermbg=16 ctermfg=69
    hi htmlH6 cterm=bold ctermbg=16 ctermfg=34
endfunction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.