Linux – How to cancel reverse search without losing text typed

bashcommand linelinux

When using reverse-search (Ctrlr) in the bash terminal , I can cancel the search using either Ctrlc or Ctrlg. Both these options will clear the text typed while searching.

However, the most common reason I need to cancel my search is when I realize the command I wanted to type is not in my history, and this often happens only after I've typed a very long command.

Is there some way to cleanly abort the search without losing everything I typed?

Best Answer

Try using the cursor movement keys, e.g. Ctrl+B or Ctrl+F.