Often I fail to find something with reverse-i-search but want to keep what I have already written. For example, typing pdflatex fails to complete to pdflatex mydocument.tex. If I then cancel it with Ctrl+c or Ctrl g, the pdflatex part is deleted as well. How can I cancel it in a way that keeps my input?

1 Answer 1


Instead of cancelling just use ALT+F (or on Ubuntu alternatively CTRL+-> to move the cursor to the end of the first word and then press CTRL+K to delete everything to the end of the line.

Now you are ready to complete your command.

  • Thanks! <kbd>Ctrl</kbd>+<kbd>-></kbd> works on Arch Linux under Z shell as well. Jul 23, 2015 at 8:14
  • 2
    Neither Alt+F nor Ctrl+→ work in my mintty/Ubuntu 14.04 LTS/bash 4.3.11(1)-release environment.
    – Abdull
    Feb 26, 2016 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.