Skip to content

Instantly share code, notes, and snippets.

@jvns
Last active April 29, 2025 15:15
Show Gist options
  • Save jvns/a138971c693623e177864aad40a57833 to your computer and use it in GitHub Desktop.
Save jvns/a138971c693623e177864aad40a57833 to your computer and use it in GitHub Desktop.
function! TakeScreenshot(name)
" Take the screenshot
call system('pngpaste static/images/' . a:name . '.png')
" Insert the image tag at the current cursor position
let l:img_tag = '<img src="/images/' . a:name . '.png">'
execute "normal! i" . l:img_tag . "\<Esc>"
echo "Screenshot saved and image tag inserted!"
endfunction
command! -nargs=1 Screenshot call TakeScreenshot(<q-args>)
" depends on `pngpaste`
" how to run it: `:Screenshot blah` will make `blah.png` and insert the image
" if you want to customize it just edit the function!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment