diff --git a/plugin/mdip.vim b/plugin/mdip.vim index 6603d42..80ab69e 100644 --- a/plugin/mdip.vim +++ b/plugin/mdip.vim @@ -181,14 +181,20 @@ function! mdip#MarkdownClipboardImage() if tmpfile == 1 return else - " let relpath = s:SaveNewFile(g:mdip_imgdir, tmpfile) - let extension = split(tmpfile, '\.')[-1] + let extension = split(tmpfile, '\.')[-1] let relpath = g:mdip_imgdir_intext . '/' . g:mdip_tmpname . '.' . extension - execute "normal! i![" . g:mdip_tmpname[0:0] - let ipos = getcurpos() - execute "normal! a" . g:mdip_tmpname[1:] . "](" . relpath . ")" - call setpos('.', ipos) - execute "normal! vt]\" + if &filetype == 'md' || &filetype == 'pandoc' + execute "normal! i![" . g:mdip_tmpname[0:0] + let ipos = getcurpos() + execute "normal! a" . g:mdip_tmpname[1:] . "](" . relpath . ")" + call setpos('.', ipos) + execute "normal! vt]\" + elseif &filetype == 'tex' + let ipos = getcurpos() + execute "normal! a" . relpath + call setpos('.', ipos) + execute "normal! vt]\" + endif endif endfunction