X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/87518b31365db356d27594988e607b9a3dd95730..3375792916db2503b81ee848eeb26c7376d23e42:/ftplugin/markdown.vim?ds=sidebyside diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index daaa2af..48fa89e 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -351,7 +351,7 @@ function! s:Toc(...) endif endif " keep track of the longest header size (heading level + title) - let l:total_len = stridx(l:line, ' ') + len(l:line) + let l:total_len = stridx(l:line, ' ') + strdisplaywidth(l:line) if l:total_len > l:header_max_len let l:header_max_len = l:total_len endif @@ -582,7 +582,20 @@ if !exists("*s:EditUrlUnderCursor") function s:EditUrlUnderCursor() let l:url = s:Markdown_GetUrlForPosition(line('.'), col('.')) if l:url != '' - execute 'edit' l:url + if get(g:, 'vim_markdown_autowrite', 0) + write + endif + if get(g:, 'vim_markdown_no_extensions_in_markdown', 0) + " use another file extension if preferred + if exists('g:vim_markdown_auto_extension_ext') + let l:ext = '.'.g:vim_markdown_auto_extension_ext + else + let l:ext = '.md' + endif + execute 'edit' fnameescape(fnamemodify(expand('%:~'), ':p:h').'/'.l:url.l:ext) + else + execute 'edit' fnameescape(l:url) + endif else echomsg 'The cursor is not on a link.' endif