Skip to content

Local Variable Code Snippet

How to declare and use a local variable

Here is a quick reference showing How to declare and use a local variable.

# Create a local variable with no assigned value
# (i.e. an empty variable)
:local AuthorName;

# Assign a value to the variable
:set AuthorName "Nigel Bowden";

# Create a local variable with an assigned value
:local BookTitle "Jaws";

# Print variable value
:put $BookTitle;

# update variable value to new value
:set BookTitle "War and Peace";

# Clear value (i.e. variable contains no value)
:set BookTitle;

# Note: local vars only exist for the lifetime of a script

Buy

Bookcover