Introduce preset/user definable variables system

I think some kind of preset and/or user definable variables will be a great addition to growing Obsidian possibilities.

Example of preset variables:

  • UName = user account name
  • Date = current date
  • Time = current time
  • Title = current note name
  • etc

It will be good to give user a way to define it’s own variables. (Special GUI needed? Or just a quick config-file setup.)

There should be a special syntax to expand variables. Something like this:
[%Date%]

Thoughts? Let’s brainstorm this!

10 Likes

Something like this is probably better suited toward a specialized text expansion program (I use aText, somewhat arbitrarily). This are going to be more fully featured than Obsidian could realistically be without taking time away from developing other features.

I have a few useful shortcuts already set up. Besdies xdate (which would be replaced with 2020-05-27, or xday (Wednesday, May 27, 2020), I also have xz set up to replace with [[(contents of clipboard)]], so I can highlight text, press CMD-x to copy, then press xz to insert it as a link.

These are mostly mean to be used as a placeholder in newly created notes. Say: %UName%-diary-%Date%, or %Cursor% - for cursor placement.

I agree, this would be very useful with new note templates. I come from VSNotes which has a similar feature, where variables can be defined in the config and then used in new note templates (both in the file name and in the note content). Examples of variables I use:

  • ISO timestamp. This is included in the note header.
  • Note title. This is included in the generated note file name and automatically inserted as the title in the note content.

A related feature I use in VSNotes is transforming the variables, specifically lowercasing the title and replacing spaces with underscores in the note title when used in the file name.

Agree with this. If we could have variables, some parts of text could autogenerate on the fly. For example, in my notes, I like to have the note title as the first line, with Header 1:

My Note

It would be nice if this was a variable such as:

#<note_title>

So that it would automatically render properly, even if the note title changes.

1 Like

I would find this very useful for generating daily notes. If the date is “2020-06-05”, I’d like to generate a title such as “Friday, June 5”.

A note for future people searching for this. (I would still like a variables system)
In v8+ there is date feature for Daily Notes re b3u question.

Go to the Daily Notes plugin and change Date Format for new daily to
“Friday, June 5”
dddd, MMMM d

And in the template if you wanted to repeat that in the markdown template.
{{date:dddd, MMMM d}}

2 Likes

Is there any feature like this now? :slight_smile:

1 Like

Would also love to know!

Does this do the job? GitHub - d-brown43/obsidian-macros