These are basic command line commands, but it turns out not everyone knows about them and they're were handy:

Use a combionation of

Ctrl + A : to move the cursor to the beginning of the line
Ctrl + E : to move the cursor to the end of the line
Ctrl + U : to clear the line from the cursor back to the beginning
Ctrl + R : search in previous commands