Plugin: Note Variables

Note Variables Plugin

Edit: v2.0.0
With this plugin you can create string variables that can be used across all your notes.

Usage

Download

You can install it directly from Options > Plugins > Search for "Note Variables".
Version 2.0.0 works a bit different from v1.0.0, you may have to change your variables into a Markdown table format if you used the previous version

Bugs, feature requests or contributions

Please report any bugs you find, or any feature request you have on the GitHub Issues page

15 Likes

where are the variables saved? Id like to manually change them

Nice plugin. I got it to work after realizing that when assigning the variable, I shouldn't type "@".

1 Like

@ is probably not the best choice.

@@ is used by the Quick Links plugin, and @ is ceretainly not the first charachter that comes to mind when thinking of a var. I think this should be configurable or set to something that has no other meaning.

2 Likes

Variables appear to be out of sync. What happens if notes with variables are synced?

Right now the variables are saved in a plugin setting that's hidden, but i'm planning to enable an option to export/import to a json file.
Still you can change the value of a variable adding it again. e.g. if I added "MyVar" with value "Content of my var", you can simply add it again: "MyVar" with "New content of my var".

If I understood you well, the plugin is made so that the variables are synchronized with the notes.
When you type a variable on a note, It will show the curren value of the variable. If you change the value of the variable, it will be reflected on the note.

Yeah I thought of that. I'll add an option to configure the prefix in the next version.
Do you have any suggestions for the default prefix?

I think the only special char that doesn't have a meaning in markdown, katex, or other plugins so far is % but I might be wrong.

As long as you add an option it shouldn't really matter too much...

2 Likes

Also the % for variable resonates with users of other environments I think, like Windows.wp-content

1 Like

Do you think that using also a sufix like %this% will be useful?
I'm thinking that will help delimiting the variable, and enable to use it in any part of the text without the need of using spaces to separate it from the previous or preceding text.

1 Like

I would prefer to not have to type another %--or any character that requires the use of a shift key. So if I had to use a character before and after, I'd probably choose "q", as in qthisq.

1 Like

I mean variables in one PC are not synchronized with other PCs.

So, it seems that manually keeping the consistency of variables among several PCs are required to keep notes synced.

1 Like

For the syntax you could also use the Generic directive syntax. So for example :var[MyCoolVariable]. It's a bit more verbose but it's less likely to confict with other plugins.

Note that these generic directives are just a proposal at this point (although it would be nice if they could add something like this as it would make it easier to support plugin-specific markdown).

2 Likes

Have you considered making the variables notes?

I used tiddlywiki for years and that was a very standard part of the whole thing, namely embedding notes into other notes.

2 Likes

Katex uses % to be comments, just like LaTeX does. Anything after % appears in the markdown, but is not rendered by katex

I think that would be another plugin though. But transclusion of notes would certainly be nice.

1 Like

If that plugin were made, I wonder how recursive transclusion between notes would be managed

what about "!" for a variable identifier?

I'll make an option to choose the prefix/sufix, so the user can choose anything convenient.


The problem with that is that if you use "d" your variables must not contain the letter "d". That's why it's more convenient for the prefix/suffix to be a special character.

You're right. Never mind about using a letter.