I accidentally typed ctrl + L in terminal and my terminal window jumped one 'screenful' size. I looked at the keyboard shortcuts in "Edit"->"Keyboard shortcuts" and didn't find that shortcut.

What does ctrl + L do and where is it defined?


Solution 1:

ctrl + L just clear the terminal screen.

It is the keyboard shortcut equivalent of the command clear -x. ref

It is property of bash, so you did not found it under keyboard shortcuts in your gnome-terminal. From man bash:

clear-screen (C-l)
          Clear the screen leaving the current line  at  the  top  of  the
          screen.   With  an  argument,  refresh  the current line without
          clearing the screen.

See a detail list of Bash Keyboard Shortcuts.

Solution 2:

If the shell you're using is not intercepting it, you are typing a "Form-feed" character in your terminal. If the terminal application does not intercept or use the keystroke in some way, Ctrl+Letter is translated to the ASCII code of the letter minus 64(1). 65 is the ASCII code of 'A', 'L' is the 12th letter -> code 76. If the shell does not know what to do of the code, it prints it.

Printing a FF char resulted in a new page on a line printer and a clear screen on the terminal (yes, I used a VT-52 back then, at 300 baud).

So Ctrl+L is 12 which is FF. In the same way, Ctrl+I is a TAB, and Ctrl+G rings the bell --- if the terminal or the shell does not intercept it, like Ctrl+C for example.

Notice from the other answer: it seems that bash do intercept CTRL-L and do a clear. Nice touch that the bash authors associated the key with a command which will do more or less the same that the ASCII code did on old terminals!

On the other hand, in my zsh the combination CTRL-I works as TAB and CTRL-H as a Backspace(2).

Old nice ASCII... (notice that letter L is at column 4, row 12, it has ASCII code 4*16+12=76).

Image from Wikimedia commons

Original Image here, from wikipedia article on ASCII.


Footnotes:

(1) Ctrl really used to clear the bit 7.

(2) this is the source of the "fail to remove word" joke you sometime find like for example "this was a bad^H^H^Hnot so nice idea"... (with normally a word stronger than bad!)