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.
This commit is contained in:
Rane Brown 2019-04-08 20:54:21 -06:00
parent 848feb43e1
commit 3bf389bf99
1 changed files with 6 additions and 4 deletions

View File

@ -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