GitHub - ferrine/md-img-paste.vim: paste image to markdown
source link: https://github.com/ferrine/md-img-paste.vim
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
md-img-paste.vim
Yet simple tool to paste images into markdown files
Use Case
You are editing a markdown file and have an image on the clipboard and want to paste it into the document as the text ![](img/image1.png)
. Instead of first copying it to that directory, you want to do it with a single <leader>p
key press in Vim. So it hooks <leader>p
, checks if you are editing a Markdown file, saves the image from the clipboard to the location img/image1.png
, and inserts ![](img/image1.png)
into the file.
Installation
Using Vundle
Plugin 'ferrine/md-img-paste.vim'
Usage
Add to .vimrc
autocmd FileType markdown nmap <silent> <leader>p :call mdip#MarkdownClipboardImage()<CR>
" there are some defaults for image directory and image name, you can change them
" let g:mdip_imgdir = 'img'
" let g:mdip_imgname = 'image'
Acknowledgements
I'm not yet perfect at writing vim plugins but I managed to do it. Thanks to Karl Yngve Lervåg and Rich for help on vi.stackexchange.com where they proposed a solution for my use case.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK