Homepage    |    GitHub    |    API    |    Wiki    |    FAQ

Plugin: Note Variables

Note Variables Plugin

With this plugin you can create string variables that can be used across all your notes.
If you use a lot the same text on different notes, this plugin could help you save time typing or remembering something.

Usage

Click on the "x1" button on the editor toolbar to add, delete or update your variables.
You can also add, remove or edit your variables directly from the note "%NoteVariables%" that will be created automatically. The note its written in JSON format. You can add variables inside or outside the "vars" property, and then click on the icon right next to the "x1" icon. The plugin will automatically put the variables where they belong in the note.


After you defined your variables, you can use them on your notes using the default "%" delimiter for your variables. You can change this on the plugin settings.

Download

You can install it directly from Options > Plugins > Search for "Note Variables".
If you installed a version under 1.0.0, you will have to uninstall it and install version 1.0.0 or greater.

Bugs, feature requests or contributions

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

Kanban board

You can see the current User Stories i'm working on for the next version of the plugin here:

11 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.