Search code examples
command-lineoctave

How to clear the command line in Octave?


In Octave, when typing command in the command line, sometimes I need to erase the whole line and restart a new command. In Matlab, erasing the text would be done with the ESC key. In Octave this does not work. The only way I found to discard the input text is using Ctrl-C. This works, but it is ugly, as it leaves remains on the screen.

Is there a key combination to clear the line in Octave?


Solution

  • There are several clearing shortcuts defined:

    • Meta-D: clear the next word1
    • Ctrl-K: clear to the end of the line
    • Ctrl-U: clear the whole line
    • Ctrl-L: clear the line and the screen

    See more examples in the octave command-line-editing section of the manual.

    For historical reasons Ctrl-U is usually controlled by your terminal rather than octave, although octave also supports it. You can test this with stty kill undef (restore with stty kill '^U').

    1 Meta is often bound to the Win key or the Alt key. If not hit the Esc key first and then the character that needs to be "metaified".