One frustrating thing that happens very often to me is that I type a long command into a command-line interface (CLI) and then realize I need to execute another command before that one. Sometimes I open a second CLI to execute that command, but at other times that's not possible. So I end up deleting the text I've already typed, typing and executing the precedent command, and finally re-typing and executing the original command.
Here are the best alternatives I know of:
In the Linux Terminal, if I have a mouse, I can carefully highlight the text with the mouse, right-click -> Copy, and clear the line with
U. When I want the copied text again, I can either
V, middle-click, or right-click -> Paste. Without a mouse, I'm lost.
In the Windows Command Prompt, if I have a mouse, I can right-click -> Mark, carefully highlight the text with the mouse,
C to copy, and hold
Backspace to clear the line. When I want the copied text again, I can right-click -> Paste. Without a mouse, I'm lost.
I feel like there should be a better way. The ideal solution to me would be to have some kind of keyboard command that stores the text I've typed on the current line for later and removes it from the line at the same time, as well as a second command that would re-insert the text on the command line. Such a solution would be faster and more comfortable because it would have fewer steps, no need to switch between the mouse and the keyboard, and no need to worry about highlighting exactly the right amount of text.