commit 3bf389bf99eafd5614ee7d37adf6e67747cdc934
parent 848feb43e169147221a22642beea1d9f93d66815
Author: Rane Brown <rane.brown@gmail.com>
Date: Mon, 8 Apr 2019 20:54:21 -0600
Don't replace spaces in link description for markdown syntax.
The option 'links_space_char' replaces spaces with the specified
character when creating a link from a visual selection. This modifies
the behavior to not replace spaces in the link description but to still
replace spaces in the filename.
Diffstat:
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/autoload/vimwiki/markdown_base.vim b/autoload/vimwiki/markdown_base.vim
@@ -110,7 +110,7 @@ endfunction
function! s:normalize_link_syntax_v()
let lnum = line('.')
let sel_save = &selection
- let &selection = "old"
+ let &selection = 'old'
let rv = @"
let rt = getregtype('"')
let done = 0
@@ -120,10 +120,12 @@ function! s:normalize_link_syntax_v()
let visual_selection = @"
let link = s:safesubstitute(vimwiki#vars#get_syntaxlocal('Weblink1Template'),
\ '__LinkUrl__', visual_selection, '')
- let link = s:safesubstitute(link, '__LinkDescription__', visual_selection, '')
- let sc = vimwiki#vars#get_wikilocal('links_space_char')
- call setreg('"', substitute(substitute(link, '\n', '', ''), '\s', sc, 'g'), visualmode())
+ " replace spaces with new character if option is set
+ let link = substitute(link, '\s', vimwiki#vars#get_wikilocal('links_space_char'), 'g')
+
+ let link = s:safesubstitute(link, '__LinkDescription__', visual_selection, '')
+ call setreg('"', substitute(link, '\n', '', ''), visualmode())
" paste result
norm! `>""pgvd