commit 1176f60ec639c4c8fd476b6a335416feeffa36ef
parent 3f8bb1261fab28cde9a1fa8a8ad5a9ef88a31fc6
Author: Ben Burrill <bburrill98@gmail.com>
Date: Sun, 22 Apr 2018 11:58:39 -0700
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.
Diffstat:
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/autoload/vimwiki/base.vim b/autoload/vimwiki/base.vim
@@ -1986,7 +1986,7 @@ function! s:normalize_link_syntax_v()
endif
" Put substitution in register " and change text
- call setreg('"', sub, 'v')
+ call setreg('"', substitute(sub, '\n', '', ''), visualmode())
normal! `>""pgvd
finally
call setreg('"', default_register_save, registertype_save)
@@ -2002,8 +2002,8 @@ function! vimwiki#base#normalize_link(is_visual_mode)
else
if !a:is_visual_mode
call s:normalize_link_syntax_n()
- elseif visualmode() ==# 'v' && line("'<") == line("'>")
- " action undefined for 'line-wise' or 'multi-line' visual mode selections
+ elseif line("'<") == line("'>")
+ " action undefined for multi-line visual mode selections
call s:normalize_link_syntax_v()
endif
endif
diff --git a/autoload/vimwiki/markdown_base.vim b/autoload/vimwiki/markdown_base.vim
@@ -122,7 +122,7 @@ function! s:normalize_link_syntax_v()
\ '__LinkUrl__', visual_selection, '')
let link = s:safesubstitute(link, '__LinkDescription__', visual_selection, '')
- call setreg('"', link, 'v')
+ call setreg('"', substitute(link, '\n', '', ''), visualmode())
" paste result
norm! `>""pgvd
@@ -141,8 +141,8 @@ function! vimwiki#markdown_base#normalize_link(is_visual_mode)
else
if !a:is_visual_mode
call s:normalize_link_syntax_n()
- elseif visualmode() ==# 'v' && line("'<") == line("'>")
- " action undefined for 'line-wise' or 'multi-line' visual mode selections
+ elseif line("'<") == line("'>")
+ " action undefined for multi-line visual mode selections
call s:normalize_link_syntax_v()
endif
endif