Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ This plugin gets clipboard content by running the `xclip` command.

install `xclip` first.

### For WSL user

Set your WSL path in .vimrc (you can check your WSL path from Windows File Explorer)
```
let g:mdip_wsl_path = '\\\\wsl.localhost\\Ubuntu-22.04'
```

## Acknowledgements
I'm not yet perfect at writing vim plugins but I managed to do it. Thanks to [Karl Yngve Lervåg](https://vi.stackexchange.com/users/21/karl-yngve-lerv%C3%A5g) and [Rich](https://vi.stackexchange.com/users/343/rich) for help on [vi.stackexchange.com](https://vi.stackexchange.com/questions/14114/paste-link-to-image-in-clipboard-when-editing-markdown) where they proposed a solution for my use case.

8 changes: 6 additions & 2 deletions plugin/mdip.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function! s:SaveFileTMPWSL(imgdir, tmpname) abort
let tmpfile = a:imgdir . '/' . a:tmpname . '.png'
let tmpfile = substitute(tmpfile, "\/", "\\\\\\", "g")
if tmpfile =~ "mnt"
let tmpfile = substitute(tmpfile, "\\\\\\\\mnt\\\\\\\\c", "C:", "g")
let tmpfile = substitute(tmpfile, '\\\\mnt\\\\\(.\)', '\1:', "g")
else
let tmpfile = '\\\\wsl\$\\Ubuntu'.tmpfile
let tmpfile = g:mdip_wsl_path.tmpfile
endif

let clip_command = 'powershell.exe -nologo -noprofile -noninteractive -sta "Add-Type -Assembly PresentationCore;'.
Expand Down Expand Up @@ -252,3 +252,7 @@ endif
if !exists('g:mdip_imgname')
let g:mdip_imgname = 'image'
endif

if !exists('g:mdip_wsl_path')
let g:mdip_wsl_path = '\\\\wsl\$\\Ubuntu'
endif