Moving around quickly
The most basic part is to move to the place you want to edit quickly. Here are the most useful shortcuts:
- Ctrl-a – Move to the start of the line.
- Ctrl-e – Move to the end of the line.
- Alt-f – Move forward a word.
- Ctrl-f – Move forward a char.
- Alt-b – Move backward a word.
- Ctrl-b – Move backward a char.
Another very common shortcut is Ctrl-L which clears the screen and reprints the current line at the top. This is useful if you are organizing your movies library and somebody enters the room.
Cut, Paste and Undo
Here is the list of most useful shortcuts for deleting text:
- Ctrl-w – Deletes from cursor position to the previous whitespace.
- Ctrl-k – Deletes from cursor position to the end of the line.
- Ctrl-d – Deletes from current character.
- Ctrl-u – Deletes from whole line.
- Alt-d – Deletes from cursor position to the end of the current word.
- Alt-DEL – Deletes from cursor position to the start of the current word.
The deleted text can be pasted (yanked) using Ctrl-y. You can use Ctrl-_ or Ctrl-X-U to undo the last editing command.
This covers the essentials. On the next parts of this series we’ll explore the more powerful abilities of readline. Feel free to leave here questions, suggestions, or perhaps your own tips and tricks.