Automatic Zettelkasten note-link naming scheme
When creating a new link within notes, using the wiki.vim openlink shortcut (return by default), it will prepend a Zettelkasten-like unique id based on current time in front of the link. It will also lowercase it and substitute spaces for dashes.
This commit is contained in:
parent
90dfacf7bd
commit
66961cae79
1 changed files with 31 additions and 2 deletions
|
@ -7,6 +7,35 @@ endif
|
|||
" filetypes to automatically enable the plugin for, seems to take file endings
|
||||
" rather than vim ft
|
||||
let g:wiki_filetypes = ['md', 'mkd', 'markdown', 'wiki']
|
||||
let g:wiki_link_extension = '.md'
|
||||
let g:wiki_link_target_type = 'md'
|
||||
let g:wiki_mappings_use_defaults = 1
|
||||
|
||||
" wiki automatic link creation
|
||||
" add .md to the end of links by default
|
||||
let g:wiki_link_extension = '.md'
|
||||
" add a link in the format [descr](target) by default
|
||||
" not in wiki format [[link|descr]]
|
||||
let g:wiki_link_target_type = 'md'
|
||||
|
||||
" Creates a Zettelkasten compatible unique datestamp
|
||||
function s:Getdatestamp()
|
||||
if !exists("*strftime")
|
||||
:echoerr "Date Stamp creation needs strftime available on system!"
|
||||
endif
|
||||
return strftime("%y%m%d%H%M")
|
||||
endfunction
|
||||
|
||||
command! Datestamp :echom s:Getdatestamp()
|
||||
|
||||
" Appends Zettelkasten timestamp to beginning of links
|
||||
function! PrependDatestamp(text) abort
|
||||
" lowercase and replace spaces with dashes (-) to make links uniform
|
||||
let l:text=substitute(tolower(a:text), '\s\+', '-', 'g')
|
||||
" prepend datestamp
|
||||
let l:text=substitute(l:text, '^', s:Getdatestamp() . ' '. '\0', 'g')
|
||||
return l:text
|
||||
endfunction
|
||||
|
||||
" sets wiki.vim to automatically apply datestamp function to links
|
||||
let g:wiki_link_target_map = "PrependDatestamp"
|
||||
|
||||
let g:wiki_list_todos = ['[ ]', '[x]']
|
||||
|
|
Loading…
Reference in a new issue