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:
parent
3396e87dbe
commit
41aa647aba
@ -2134,7 +2134,8 @@ function! s:normalize_link_syntax_v()
|
||||
endif
|
||||
|
||||
" 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
|
||||
finally
|
||||
call setreg('"', default_register_save, registertype_save)
|
||||
|
@ -122,7 +122,8 @@ function! s:normalize_link_syntax_v()
|
||||
\ '__LinkUrl__', 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
|
||||
norm! `>""pgvd
|
||||
|
@ -269,6 +269,7 @@ function! s:populate_wikilocal_options()
|
||||
\ 'exclude_files': {'type': type([]), 'default': []},
|
||||
\ 'ext': {'type': type(''), 'default': '.wiki', '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},
|
||||
\ 'maxhi': {'type': type(0), 'default': 0, 'min': 0, 'max': 1},
|
||||
\ 'nested_syntaxes': {'type': type({}), 'default': {}},
|
||||
|
@ -2055,6 +2055,21 @@ converted to HTML at the moment.
|
||||
To use Markdown's wiki markup: >
|
||||
let g:vimwiki_list = [{'path': '~/my_site/',
|
||||
\ '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*
|
||||
|
Loading…
Reference in New Issue
Block a user