Variables
Declaring a variable
A variable is a named value that you can refer to in your calculations.
You can create a variable by specifying the variable's name followed by an =
sign, and then the value of the variable can follow after the equals sign.
Variable names can contain spaces.
people = 3 price per day = $26 days = 4 cost is people * price per day * days
As can be seen, standing with the cursor in the fourth line, the individual variables have been underlined with different colors, and the color corresponding to each variable appeared on the left side of the lines they have been defined at.
These colors help to identify and find where the variables used in an expression are defined.
It works the other way around too: by placing the cursor on a line of a variable declaration (e.g., the second line),
that particular variable starts to flash in every expression where it is used, thereby helping the reader to see where exactly a variable is used in a note.
In this short document, of course, it's not a big help, but it is mostly useful in more complex notes.
By pressing CTRL B while standing on a variable with the cursor, you can jump to its declaration line.
Reassigning variables
New values can be freely reassigned to variables, in the following expressions, the last assigned value will be used.
# 2022 people = 3 price per day = $26 days = 4 cost is people * price per day * days # 2024 In '2024 Jane and Robert joined to the vacation people = people + 2 cost is people * price per day * days
Value of subexpressions
If you are curious about the value of a subexpression within a more complex expression, simply select the particular subexpression with the mouse or keyboard SHIFT+cursor.
If the selected subexpression is valid, its value will appear above the selection.
Total value of selected lines
If you are interested in the sum of only a selected few lines from several, simply highlight them and similarly, their summed value will appear.
Select only the '(2 + 3) part 1 + 2 + 3 + 4 + 5 Now select the lines that contain '2 and '3 1 2 3 4 5
Inserting a variable with line selection
Instead of typing the name of the variable you want to reference, you can navigate to the line of the variable declaration holding down ALT, then pressing up/down arrows.
Upon releasing the ALT key, the name of the variable will be automatically inserted.
Insurance price A = $250/year Insurance price B = $300/year Insurance price C = $375/year It will cost 3year *
With the cursor positioned behind the 3year *
expression in the fourth line, press the ALT ↑ arrow and keep the ALT key down.
Then, using the ↑/↓ arrows, select the price that you prefer, and once you have made your selection, release the ALT key.
Implicit sum
variable
A variable named sum
is implicitly defined for you, and within each header, it automatically contains the total of the lines from the header to the use of the sum
variable, provided the results of the lines are addable.
# Trip 2021 accomodation $20 gas $35 food $16 sum # Trip 2023 accomodation $40 gas $75 food $100 sum
The value of sum
can be reset.
For Jane accomodation $20 gas $35 food $16 sum sum = $0 // Reset sum For Jack accomodation $20 gas $35 food $16 sum