File: Commands-for-History.html

package info (click to toggle)
octave 10.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 145,388 kB
  • sloc: cpp: 335,976; ansic: 82,241; fortran: 20,963; objc: 9,402; sh: 8,756; yacc: 4,392; lex: 4,333; perl: 1,544; java: 1,366; awk: 1,259; makefile: 659; xml: 192
file content (406 lines) | stat: -rw-r--r-- 25,322 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Commands for History (GNU Octave (version 10.3.0))</title>

<meta name="description" content="Commands for History (GNU Octave (version 10.3.0))">
<meta name="keywords" content="Commands for History (GNU Octave (version 10.3.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Command-Line-Editing.html" rel="up" title="Command Line Editing">
<link href="Customizing-readline.html" rel="next" title="Customizing readline">
<link href="Commands-for-Completion.html" rel="prev" title="Commands for Completion">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
kbd.kbd {font-style: oblique}
kbd.key {font-style: normal}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">


</head>

<body lang="en">
<div class="subsection-level-extent" id="Commands-for-History">
<div class="nav-panel">
<p>
Next: <a href="Customizing-readline.html" accesskey="n" rel="next">Customizing <code class="code">readline</code></a>, Previous: <a href="Commands-for-Completion.html" accesskey="p" rel="prev">Letting Readline Type for You</a>, Up: <a href="Command-Line-Editing.html" accesskey="u" rel="up">Command Line Editing</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsection" id="Commands-for-Manipulating-the-History"><span>2.4.5 Commands for Manipulating the History<a class="copiable-link" href="#Commands-for-Manipulating-the-History"> &para;</a></span></h4>
<a class="index-entry-id" id="index-command-history"></a>
<a class="index-entry-id" id="index-input-history"></a>
<a class="index-entry-id" id="index-history-of-commands"></a>

<p>Octave normally keeps track of the commands you type so that you can
recall previous commands to edit or execute them again.  When you exit
Octave, the most recent commands you have typed, up to the number
specified by the variable <code class="code">history_size</code>, are saved in a file.
When Octave starts, it loads an initial list of commands from the file
named by the variable <code class="code">history_file</code>.
</p>
<p>Here are the commands for simple browsing and searching the history
list.
</p>
<dl class="table">
<dt><kbd class="kbd"><kbd class="key">LFD</kbd></kbd></dt>
<dt><kbd class="kbd"><kbd class="key">RET</kbd></kbd></dt>
<dd><p>Accept the current line regardless of where the cursor is.  If the line is
non-empty, add it to the history list.  If the line was a history
line, then restore the history line to its original state.
</p>
</dd>
<dt><kbd class="kbd">C-p</kbd></dt>
<dd><p>Move &lsquo;up&rsquo; through the history list.
</p>
</dd>
<dt><kbd class="kbd">C-n</kbd></dt>
<dd><p>Move &lsquo;down&rsquo; through the history list.
</p>
</dd>
<dt><kbd class="kbd">M-&lt;</kbd></dt>
<dd><p>Move to the first line in the history.
</p>
</dd>
<dt><kbd class="kbd">M-&gt;</kbd></dt>
<dd><p>Move to the end of the input history, i.e., the line you are entering!
</p>
</dd>
<dt><kbd class="kbd">C-r</kbd></dt>
<dd><p>Search backward starting at the current line and moving &lsquo;up&rsquo; through
the history as necessary.  This is an incremental search.
</p>
</dd>
<dt><kbd class="kbd">C-s</kbd></dt>
<dd><p>Search forward starting at the current line and moving &lsquo;down&rsquo; through
the history as necessary.
</p></dd>
</dl>

<p>On most terminals, you can also use the up and down arrow keys in place
of <kbd class="kbd">C-p</kbd> and <kbd class="kbd">C-n</kbd> to move through the history list.
</p>
<p>In addition to the keyboard commands for moving through the history
list, Octave provides three functions for viewing, editing, and
re-running chunks of commands from the history list.
</p>
<a class="anchor" id="XREFhistory"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-history-1"><span><strong class="def-name">history</strong><a class="copiable-link" href="#index-history-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-history-2"><span><strong class="def-name">history</strong> <code class="def-code-arguments"><var class="var">opt1</var> &hellip;</code><a class="copiable-link" href="#index-history-2"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-history-3"><span><code class="def-type"><var class="var">H</var> =</code> <strong class="def-name">history</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-history-3"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-history-4"><span><code class="def-type"><var class="var">H</var> =</code> <strong class="def-name">history</strong> <code class="def-code-arguments">(<var class="var">opt1</var>, &hellip;)</code><a class="copiable-link" href="#index-history-4"> &para;</a></span></dt>
<dd><p>If invoked with no arguments, <code class="code">history</code> displays a list of commands
that you have executed.
</p>
<p>Valid options are:
</p>
<dl class="table">
<dt><code class="code"><var class="var">n</var></code></dt>
<dt><code class="code">-<var class="var">n</var></code></dt>
<dd><p>Display only the most recent <var class="var">n</var> lines of history.
</p>
</dd>
<dt><code class="code">-c</code></dt>
<dd><p>Clear the history list.
</p>
</dd>
<dt><code class="code">-q</code></dt>
<dd><p>Don&rsquo;t number the displayed lines of history.  This is useful for cutting
and pasting commands using the X Window System.
</p>
</dd>
<dt><code class="code">-r <var class="var">file</var></code></dt>
<dd><p>Read the file <var class="var">file</var>, appending its contents to the current
history list.  If the name is omitted, use the default history file
(normally <samp class="file">~/.octave_hist</samp>).
</p>
</dd>
<dt><code class="code">-w <var class="var">file</var></code></dt>
<dd><p>Write the current history to the file <var class="var">file</var>.  If the name is
omitted, use the default history file (normally <samp class="file">~/.octave_hist</samp>).
</p></dd>
</dl>

<p>For example, to display the five most recent commands that you have
typed without displaying line numbers, use the command
<kbd class="kbd">history -q 5</kbd>.
</p>
<p>If invoked with a single output argument, the history will be saved to that
argument as a cell string and will not be output to screen.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFedit_005fhistory">edit_history</a>, <a class="ref" href="#XREFrun_005fhistory">run_history</a>.
</p></dd></dl>


<a class="anchor" id="XREFedit_005fhistory"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-edit_005fhistory"><span><strong class="def-name">edit_history</strong><a class="copiable-link" href="#index-edit_005fhistory"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-edit_005fhistory-1"><span><strong class="def-name">edit_history</strong> <code class="def-code-arguments"><var class="var">cmd_number</var></code><a class="copiable-link" href="#index-edit_005fhistory-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-edit_005fhistory-2"><span><strong class="def-name">edit_history</strong> <code class="def-code-arguments"><var class="var">first</var> <var class="var">last</var></code><a class="copiable-link" href="#index-edit_005fhistory-2"> &para;</a></span></dt>
<dd><p>Edit the history list using the editor named by the variable <code class="env">EDITOR</code>.
</p>
<p>The commands to be edited are first copied to a temporary file.  When you
exit the editor, Octave executes the commands that remain in the file.  It
is often more convenient to use <code class="code">edit_history</code> to define functions
rather than attempting to enter them directly on the command line.
The block of commands is executed as soon as you exit the editor.
To avoid executing any commands, simply delete all the lines from the buffer
before leaving the editor.
</p>
<p>When invoked with no arguments, edit the previously executed command;
With one argument, edit the specified command <var class="var">cmd_number</var>;
With two arguments, edit the list of commands between <var class="var">first</var> and
<var class="var">last</var>.  Command number specifiers may also be negative where -1
refers to the most recently executed command.
The following are equivalent and edit the most recently executed command.
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">edit_history
edit_history -1
</pre></div></div>

<p>When using ranges, specifying a larger number for the first command than the
last command reverses the list of commands before they are placed in the
buffer to be edited.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFrun_005fhistory">run_history</a>, <a class="ref" href="#XREFhistory">history</a>.
</p></dd></dl>


<a class="anchor" id="XREFrun_005fhistory"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-run_005fhistory"><span><strong class="def-name">run_history</strong><a class="copiable-link" href="#index-run_005fhistory"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-run_005fhistory-1"><span><strong class="def-name">run_history</strong> <code class="def-code-arguments"><var class="var">cmd_number</var></code><a class="copiable-link" href="#index-run_005fhistory-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-run_005fhistory-2"><span><strong class="def-name">run_history</strong> <code class="def-code-arguments"><var class="var">first</var> <var class="var">last</var></code><a class="copiable-link" href="#index-run_005fhistory-2"> &para;</a></span></dt>
<dd><p>Run commands from the history list.
</p>
<p>When invoked with no arguments, run the previously executed command;
</p>
<p>With one argument, run the specified command <var class="var">cmd_number</var>;
</p>
<p>With two arguments, run the list of commands between <var class="var">first</var> and
<var class="var">last</var>.  Command number specifiers may also be negative where -1
refers to the most recently executed command.  For example, the command
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">run_history
     OR
run_history -1
</pre></div></div>

<p>executes the most recent command again.
The command
</p>
<div class="example">
<pre class="example-preformatted">run_history 13 169
</pre></div>

<p>executes commands 13 through 169.
</p>
<p>Specifying a larger number for the first command than the last command
reverses the list of commands before executing them.
For example:
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">disp (1)
disp (2)
run_history -1 -2
&rArr;
 2
 1
</pre></div></div>


<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFedit_005fhistory">edit_history</a>, <a class="ref" href="#XREFhistory">history</a>.
</p></dd></dl>


<p>Octave also allows you customize the details of when, where, and how history
is saved.
</p>
<a class="anchor" id="XREFhistory_005fsave"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-history_005fsave"><span><code class="def-type"><var class="var">val</var> =</code> <strong class="def-name">history_save</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-history_005fsave"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-history_005fsave-1"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">history_save</strong> <code class="def-code-arguments">(<var class="var">new_val</var>)</code><a class="copiable-link" href="#index-history_005fsave-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-history_005fsave-2"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">history_save</strong> <code class="def-code-arguments">(<var class="var">new_val</var>, &quot;local&quot;)</code><a class="copiable-link" href="#index-history_005fsave-2"> &para;</a></span></dt>
<dd><p>Query or set the internal variable that controls whether commands entered
on the command line are saved in the history file.
</p>
<p>When called from inside a function with the <code class="code">&quot;local&quot;</code> option, the
variable is changed locally for the function and any subroutines it calls.
The original variable value is restored when exiting the function.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFhistory_005fcontrol">history_control</a>, <a class="ref" href="#XREFhistory_005ffile">history_file</a>, <a class="ref" href="#XREFhistory_005fsize">history_size</a>, <a class="ref" href="#XREFhistory_005ftimestamp_005fformat_005fstring">history_timestamp_format_string</a>.
</p></dd></dl>


<a class="anchor" id="XREFhistory_005fcontrol"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-history_005fcontrol"><span><code class="def-type"><var class="var">val</var> =</code> <strong class="def-name">history_control</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-history_005fcontrol"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-history_005fcontrol-1"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">history_control</strong> <code class="def-code-arguments">(<var class="var">new_val</var>)</code><a class="copiable-link" href="#index-history_005fcontrol-1"> &para;</a></span></dt>
<dd><p>Query or set the internal variable that specifies how commands are saved
to the history list.
</p>
<p>The default value is an empty character string, but may be overridden by the
environment variable <code class="env">OCTAVE_HISTCONTROL</code><!-- /@w -->.
</p>
<p>The value of <code class="code">history_control</code> is a colon-separated list of values
controlling how commands are saved on the history list.  If the list
of values includes <code class="code">ignorespace</code>, lines which begin with a space
character are not saved in the history list.  A value of <code class="code">ignoredups</code>
causes lines matching the previous history entry to not be saved.
A value of <code class="code">ignoreboth</code> is shorthand for <code class="code">ignorespace</code> and
<code class="code">ignoredups</code>.  A value of <code class="code">erasedups</code> causes all previous lines
matching the current line to be removed from the history list before that
line is saved.  Any value not in the above list is ignored.  If
<code class="code">history_control</code> is the empty string, all commands are saved on
the history list, subject to the value of <code class="code">history_save</code>.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFhistory_005ffile">history_file</a>, <a class="ref" href="#XREFhistory_005fsize">history_size</a>, <a class="ref" href="#XREFhistory_005ftimestamp_005fformat_005fstring">history_timestamp_format_string</a>, <a class="ref" href="#XREFhistory_005fsave">history_save</a>.
</p></dd></dl>


<a class="anchor" id="XREFhistory_005ffile"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-history_005ffile"><span><code class="def-type"><var class="var">val</var> =</code> <strong class="def-name">history_file</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-history_005ffile"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-history_005ffile-1"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">history_file</strong> <code class="def-code-arguments">(<var class="var">new_val</var>)</code><a class="copiable-link" href="#index-history_005ffile-1"> &para;</a></span></dt>
<dd><p>Query or set the internal variable that specifies the name of the file used to
store command history.
</p>
<p>All future commands issued during the current Octave session will be written to
this new file (if the current setting of <code class="code">history_save</code> allows for this).
</p>
<p>The default value is <samp class="file"><code class="env">$DATA</code><!-- /@w -->/octave/history</samp>, where
<code class="env">$DATA</code><!-- /@w -->&nbsp;is the platform-specific location for (roaming) user data files
(e.g., <code class="env">$XDG_DATA_HOME</code><!-- /@w -->&nbsp;or, if that is not set, <samp class="file">~/.local/share</samp>
on Unix-like operating systems or <code class="env">%APPDATA%</code><!-- /@w -->&nbsp;on Windows).  The
default value may be overridden by the environment variable
<code class="env">OCTAVE_HISTFILE</code><!-- /@w -->.
</p>
<p>Programming Notes:
</p>
<p>If you want to permanently change the location of Octave&rsquo;s history file you
need to issue the <code class="code">history_file</code> command in every new Octave session.
This can be achieved by using Octave&rsquo;s <samp class="file">.octaverc</samp> startup file.
</p>
<p>If you also want to read the saved history commands of past Octave sessions
from this different history file, then you need to use the additional command
<code class="code">history -r</code> after setting the new value of the history file.  Example
code in Octave&rsquo;s startup file to do this might look like this:
</p>
<div class="example">
<div class="group"><pre class="example-preformatted">history_file (&quot;~/new/.octave_hist&quot;);
if (exist (history_file ()))
  history (&quot;-r&quot;, history_file());
endif
</pre></div></div>


<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFhistory">history</a>, <a class="ref" href="#XREFhistory_005fcontrol">history_control</a>, <a class="ref" href="#XREFhistory_005fsave">history_save</a>, <a class="ref" href="#XREFhistory_005fsize">history_size</a>, <a class="ref" href="#XREFhistory_005ftimestamp_005fformat_005fstring">history_timestamp_format_string</a>.
</p></dd></dl>


<a class="anchor" id="XREFhistory_005fsize"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-history_005fsize"><span><code class="def-type"><var class="var">val</var> =</code> <strong class="def-name">history_size</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-history_005fsize"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-history_005fsize-1"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">history_size</strong> <code class="def-code-arguments">(<var class="var">new_val</var>)</code><a class="copiable-link" href="#index-history_005fsize-1"> &para;</a></span></dt>
<dd><p>Query or set the internal variable that specifies how many entries
to store in the history file.
</p>
<p>The default value is <code class="code">1000</code>, but may be overridden by the environment
variable <code class="env">OCTAVE_HISTSIZE</code><!-- /@w -->.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFhistory_005ffile">history_file</a>, <a class="ref" href="#XREFhistory_005ftimestamp_005fformat_005fstring">history_timestamp_format_string</a>, <a class="ref" href="#XREFhistory_005fsave">history_save</a>.
</p></dd></dl>


<a class="anchor" id="XREFhistory_005ftimestamp_005fformat_005fstring"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-history_005ftimestamp_005fformat_005fstring"><span><code class="def-type"><var class="var">val</var> =</code> <strong class="def-name">history_timestamp_format_string</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-history_005ftimestamp_005fformat_005fstring"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-history_005ftimestamp_005fformat_005fstring-1"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">history_timestamp_format_string</strong> <code class="def-code-arguments">(<var class="var">new_val</var>)</code><a class="copiable-link" href="#index-history_005ftimestamp_005fformat_005fstring-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-history_005ftimestamp_005fformat_005fstring-2"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">history_timestamp_format_string</strong> <code class="def-code-arguments">(<var class="var">new_val</var>, &quot;local&quot;)</code><a class="copiable-link" href="#index-history_005ftimestamp_005fformat_005fstring-2"> &para;</a></span></dt>
<dd><p>Query or set the internal variable that specifies the format string
for the comment line that is written to the history file when Octave
exits.
</p>
<p>The format string is passed to <code class="code">strftime</code>.  The default value is
</p>
<div class="example">
<pre class="example-preformatted">&quot;# Octave VERSION, %a %b %d %H:%M:%S %Y %Z &lt;USER@HOST&gt;&quot;
</pre></div>

<p>When called from inside a function with the <code class="code">&quot;local&quot;</code> option, the
variable is changed locally for the function and any subroutines it calls.
The original variable value is restored when exiting the function.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="Timing-Utilities.html#XREFstrftime">strftime</a>, <a class="ref" href="#XREFhistory_005ffile">history_file</a>, <a class="ref" href="#XREFhistory_005fsize">history_size</a>, <a class="ref" href="#XREFhistory_005fsave">history_save</a>.
</p></dd></dl>


<a class="anchor" id="XREFEDITOR"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-EDITOR"><span><code class="def-type"><var class="var">val</var> =</code> <strong class="def-name">EDITOR</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-EDITOR"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-EDITOR-1"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">EDITOR</strong> <code class="def-code-arguments">(<var class="var">new_val</var>)</code><a class="copiable-link" href="#index-EDITOR-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-EDITOR-2"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">EDITOR</strong> <code class="def-code-arguments">(<var class="var">new_val</var>, &quot;local&quot;)</code><a class="copiable-link" href="#index-EDITOR-2"> &para;</a></span></dt>
<dd><p>Query or set the internal variable that specifies the default text editor when
using the CLI.
</p>
<p>The default value is taken from the environment variable
<code class="env">EDITOR</code><!-- /@w -->&nbsp;when Octave starts.  If the environment variable is not
initialized, <code class="env">EDITOR</code><!-- /@w -->&nbsp;will be set to <code class="code">&quot;emacs&quot;</code>.
</p>
<p><em class="emph">Note:</em> This setting applies when running the CLI.  When using the
Octave GUI the default editor is specified in the Editor tab of Preferences.
</p>
<p>When called from inside a function with the <code class="code">&quot;local&quot;</code> option, the
variable is changed locally for the function and any subroutines it calls.
The original variable value is restored when exiting the function.
</p>

<p><strong class="strong">See also:</strong> <a class="ref" href="Function-Files.html#XREFedit">edit</a>, <a class="ref" href="#XREFedit_005fhistory">edit_history</a>.
</p></dd></dl>


</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Customizing-readline.html">Customizing <code class="code">readline</code></a>, Previous: <a href="Commands-for-Completion.html">Letting Readline Type for You</a>, Up: <a href="Command-Line-Editing.html">Command Line Editing</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>