# set-variable(2)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

set-variable - Assign a new value to a variable
unset-variable - Delete a variable

## SYNOPSIS

set-variable "variable" "value" (C-x v)
unset-variable "variable"

## DESCRIPTION

set-variable sets the given register (# name), system ($ name), global (% name), buffer (: name) or command (. name) variable to the given value, erasing its current value. The returned value of an undefined variable is the string "`ERROR`", this maybe used to determine whether a variable has been set.

unset-variable unsets the given variable so that it no longer exists. The variable must be a global (%), buffer (:) or command (.) variable, system ($) variables cannot be unset.

The value may be quoted or unquoted, if there are any white space characters, or characters open to other interpretation (e.g. @wc) in value then quotes should be used.

value may contain control characters which are delimited by a back slash (\) which include:-

`\n` newline
`\t` tab
`\\` backslash

Confusion sometimes arises in macros with the back slash, as the back slashes are dereferenced when set. Commands such as replace-string(2) where the command itself utilizes back slashes. In this case the number of back slashes should be doubled as the variable contents under go two stages of dereferencing.

## SEE ALSO

describe-variable(2), list-variables(2), &set(4).

Variables
Introduction to Variable Functions
Register Variables

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>