From: Richard Fletcher Date: Fri, 9 Sep 2016 11:20:41 +0000 (+0100) Subject: Auto write option on following a link for edit X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/e786f1a4b62fa10d748f38e03b706117feab63f1?ds=sidebyside;hp=-c Auto write option on following a link for edit When you follow a link with "ge" you get an error if there are changes to write, this ensures a write is done and the navigation is completed --- e786f1a4b62fa10d748f38e03b706117feab63f1 diff --git a/README.md b/README.md index c1289f5..8318f7d 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,13 @@ This is super useful for GitLab and GitHub wiki repositories. Normal behaviour would be that vim-markup required you to do this `[link text](link-url.md)`, but this is not how the Gitlab and GitHub wiki repositories work. So this option adds some consistency between the two. +### Auto-write when following link + +If you follow a link like this `[link text](link-url)` using the "ge" shortcut, this option will automatically save any edits you made before moving you: + +```vim +let g:vim_markdown_autowrite = 1 +``` ## Mappings diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim index ef9cf59..be55efa 100644 --- a/ftplugin/markdown.vim +++ b/ftplugin/markdown.vim @@ -582,6 +582,9 @@ if !exists("*s:EditUrlUnderCursor") function s:EditUrlUnderCursor() let l:url = s:Markdown_GetUrlForPosition(line('.'), col('.')) if l:url != '' + if get(g:, 'vim_markdown_autowrite', 0) + write + endif if get(g:, 'vim_markdown_no_extensions_in_markdown', 0) execute 'edit' fnamemodify(expand('%:~'), ':p:h').'/'.l:url.'.md' else