Swap Characters & Words in Terminal
Let’s learn how to quickly fix typos by swapping characters and words in the terminal.
Let’s take this command with a typo for example:
You can use CTRL + T to swap the first character from the left and right side of the cursor.
Set your cursor between the
c characters and then press CTRL + T.
eh|co hey will become
🎥 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?
The following command doesn’t exist:
Press ALT + T to swap the words and the terminal will show the correct command:
Let’s try it again. Type the following in your terminal:
Press ALT + T.
The words are swapped and the output is
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.