Allow any visual mode to be used to create a link
The only real condition we care about is whether the selection is contained within a single line. It is practical to do something like V<CR> to link a whole line, and AFAIK there is no reason for why that doesn't work.
This commit is contained in:
parent
3f8bb1261f
commit
1176f60ec6
@ -1986,7 +1986,7 @@ function! s:normalize_link_syntax_v()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" Put substitution in register " and change text
|
" Put substitution in register " and change text
|
||||||
call setreg('"', sub, 'v')
|
call setreg('"', substitute(sub, '\n', '', ''), visualmode())
|
||||||
normal! `>""pgvd
|
normal! `>""pgvd
|
||||||
finally
|
finally
|
||||||
call setreg('"', default_register_save, registertype_save)
|
call setreg('"', default_register_save, registertype_save)
|
||||||
@ -2002,8 +2002,8 @@ function! vimwiki#base#normalize_link(is_visual_mode)
|
|||||||
else
|
else
|
||||||
if !a:is_visual_mode
|
if !a:is_visual_mode
|
||||||
call s:normalize_link_syntax_n()
|
call s:normalize_link_syntax_n()
|
||||||
elseif visualmode() ==# 'v' && line("'<") == line("'>")
|
elseif line("'<") == line("'>")
|
||||||
" action undefined for 'line-wise' or 'multi-line' visual mode selections
|
" action undefined for multi-line visual mode selections
|
||||||
call s:normalize_link_syntax_v()
|
call s:normalize_link_syntax_v()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -122,7 +122,7 @@ function! s:normalize_link_syntax_v()
|
|||||||
\ '__LinkUrl__', visual_selection, '')
|
\ '__LinkUrl__', visual_selection, '')
|
||||||
let link = s:safesubstitute(link, '__LinkDescription__', visual_selection, '')
|
let link = s:safesubstitute(link, '__LinkDescription__', visual_selection, '')
|
||||||
|
|
||||||
call setreg('"', link, 'v')
|
call setreg('"', substitute(link, '\n', '', ''), visualmode())
|
||||||
|
|
||||||
" paste result
|
" paste result
|
||||||
norm! `>""pgvd
|
norm! `>""pgvd
|
||||||
@ -141,8 +141,8 @@ function! vimwiki#markdown_base#normalize_link(is_visual_mode)
|
|||||||
else
|
else
|
||||||
if !a:is_visual_mode
|
if !a:is_visual_mode
|
||||||
call s:normalize_link_syntax_n()
|
call s:normalize_link_syntax_n()
|
||||||
elseif visualmode() ==# 'v' && line("'<") == line("'>")
|
elseif line("'<") == line("'>")
|
||||||
" action undefined for 'line-wise' or 'multi-line' visual mode selections
|
" action undefined for multi-line visual mode selections
|
||||||
call s:normalize_link_syntax_v()
|
call s:normalize_link_syntax_v()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user