Add option to set a character which replaces spaces when creating links.

The wikilocal option links_space_char will be used to replace any spaces
when creating a new wiki link and page. This only affects link creation
with a visual selection.
This commit is contained in:
Rane Brown 2019-03-31 21:16:44 -06:00
parent 3396e87dbe
commit 41aa647aba
4 changed files with 20 additions and 2 deletions

View File

@ -2134,7 +2134,8 @@ function! s:normalize_link_syntax_v()
endif endif
" Put substitution in register " and change text " Put substitution in register " and change text
call setreg('"', substitute(sub, '\n', '', ''), visualmode()) let sc = vimwiki#vars#get_wikilocal('links_space_char')
call setreg('"', substitute(substitute(sub, '\n', '', ''), '\s', sc, 'g'), visualmode())
normal! `>""pgvd normal! `>""pgvd
finally finally
call setreg('"', default_register_save, registertype_save) call setreg('"', default_register_save, registertype_save)

View File

@ -122,7 +122,8 @@ 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('"', substitute(link, '\n', '', ''), visualmode()) let sc = vimwiki#vars#get_wikilocal('links_space_char')
call setreg('"', substitute(substitute(link, '\n', '', ''), '\s', sc, 'g'), visualmode())
" paste result " paste result
norm! `>""pgvd norm! `>""pgvd

View File

@ -269,6 +269,7 @@ function! s:populate_wikilocal_options()
\ 'exclude_files': {'type': type([]), 'default': []}, \ 'exclude_files': {'type': type([]), 'default': []},
\ 'ext': {'type': type(''), 'default': '.wiki', 'min_length': 1}, \ 'ext': {'type': type(''), 'default': '.wiki', 'min_length': 1},
\ 'index': {'type': type(''), 'default': 'index', 'min_length': 1}, \ 'index': {'type': type(''), 'default': 'index', 'min_length': 1},
\ 'links_space_char': {'type': type(''), 'default': ' ', 'min_length': 1},
\ 'list_margin': {'type': type(0), 'default': -1, 'min': -1}, \ 'list_margin': {'type': type(0), 'default': -1, 'min': -1},
\ 'maxhi': {'type': type(0), 'default': 0, 'min': 0, 'max': 1}, \ 'maxhi': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
\ 'nested_syntaxes': {'type': type({}), 'default': {}}, \ 'nested_syntaxes': {'type': type({}), 'default': {}},

View File

@ -2055,6 +2055,21 @@ converted to HTML at the moment.
To use Markdown's wiki markup: > To use Markdown's wiki markup: >
let g:vimwiki_list = [{'path': '~/my_site/', let g:vimwiki_list = [{'path': '~/my_site/',
\ 'syntax': 'markdown', 'ext': '.md'}] \ 'syntax': 'markdown', 'ext': '.md'}]
*vimwiki-option-links_space_char*
------------------------------------------------------------------------------
Key Default value~
links_space_char ' '
Description~
Set the character (or string) used to replace spaces when creating a link. For
example, setting '_' would transform the string 'my link' into [[my_link]] and
the created file would be my_link.wiki. The default behavior does not replace
spaces.
To set the space replacement character: >
let g:vimwiki_list = [{'path': '~/my_site/',
\ 'links_space_char': '_'}]
< <
*vimwiki-option-template_path* *vimwiki-option-template_path*