Let’s learn how to quickly fix typos by swapping characters and words in the terminal.
Swap characters
Let’s take this command with a typo for example:
ehco hey
You can use CTRL + T to swap the first character from the left and right side of the cursor.
Set your cursor between the h
and c
characters and then press CTRL + T.
eh|co hey
will become echo hey
🎥 Want to watch a video to supplement your reading? Check this out:
If you cannot remember the command, know that the letter T comes from the word transpose.
“To transpose” means to change the position, order, or sequence of something.
In our case, the characters.
Did you know that we can swap words too?
Swap words
The following command doesn’t exist:
la -ls
Press ALT + T to swap the words and the terminal will show the correct command:
ls -la
Let’s try it again. Type the following in your terminal:
hey echo
Press ALT + T.
The words are swapped and the output is echo hey
.
Happy bashing 😊
Let me know what you think about this article in the comments section below.
If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.