VTimofeenko / confluencewiki-img-paste.vim

paste images to confluencewiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

This is a fork of md-img-paste.vim that changes the syntax from

![](img/image1.png)

to

!image1.png!

To comply with Confluence Wiki markup

Installation

Using Vundle

Plugin 'SabbathHex/confluencewiki-img-paste.vim'

Additional options

The behavior is controlled by a new global variable g:mdip_behavior. If not set, the standard behavior is followed. If set to "confluencewiki" — the image is pasted with confluencewiki markup.

Original README follows.

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.

By default, the location of the saved file (img/image1.png) and the in-text reference (![](img/image1.png) are identical. You can change this behavior by specifying an absolute path to save the file (let g:mdip_imgdir_absolute = /absolute/path/to/imgdir on Linux) and a different path for in-text references (let g:mdip_imdir_intext = /relative/path/to/imgdir on Linux).

Usage

Add to .vimrc

autocmd FileType markdown nmap <buffer><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'

For Linux user

This plugin gets clipboard content by running the xclip command.

Install xclip first.

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.

About

paste images to confluencewiki


Languages

Language:Vim Script 95.3%Language:Shell 4.7%