michal-h21 / vim-zettel

VimWiki addon for managing notes according to Zettelkasten method
MIT License
555 stars 72 forks source link

Generate ID in template #118

Closed sebastianbock17 closed 2 years ago

sebastianbock17 commented 2 years ago

How would it be possible, to insert a variable, like %id into the template, which behaves the same way as %title or %date, giving just the ID prefix which is also used for the filename?

e.g. when I create a new zettel, 202201101817-Title and the template.tpl containing:

# %id %title

resulting to:

# 202201101817 Title

How would that be possible?

sebastianbock17 commented 2 years ago

Thank you so much for the generous commenting, @michal-h21 !!

I came up with a very simple solution changing just the date_format variable in my .vimrc

  let g:zettel_date_format = "%Y%m%d%H%M" "acting as my id

So now, by using the %date variable in the template acting as the ID,

# %date %title

I got to the result I was looking for:

# 202201151258 Title

Again thanks a lot for this package, reading through the plugin files is also a great way to learn how it works, as everything is so well documented. :)

michal-h21 commented 2 years ago

It should be possible to use %id in the current version.