10 Keyboard Shortcuts for Text Navigation & Manipulation in the Command Line
We recently covered 12 keyboard shortcuts to help navigate around and manipulate text in Mac OS X, and now we’ll show you a handful of similar tricks for use at the command line. These shortcuts can be used just about anywhere in the Terminal, including the bash prompt.
7 Terminal Navigation Shortcuts
Navigate around blocks of texts faster with the following shortcuts:
- Jump to Beginning of Line – Control+A
- Jump to End of Line – Control+E
- Go to Next Line – Control+N
- Go to Previous Line – Control+P
- Delete Previous Word – Control+W
- Delete Line from Cursor to Beginning – Control+U
- Delete Line from Cursor to End – Control+K
Of course you can also use the arrow keys to navigate within text blocks and to place the cursor for using all commands mentioned.
3 Cutting & Pasting Shortcuts for the Command Line
The command line also has it’s own version of cut and paste, called “kill” and “yank”, and you can reuse two previously mentioned commands for this purpose:
- Cut from Cursor to Beginning of Line – Control+U
- Cut from Cursor to End of Line – Control+K
- Paste Previously Cut Text at Cursor – Control+Y
Because the latter two kill and yank commands do not overwrite the clipboard buffer, they can function as a secondary cut & paste command in many GUI based Mac OS X apps as well.
Enjoy this? Check out more command line tips in our archives.
Thanks to Josh who pointed out some these commands in the comments
[…] Option+M to return to the beginning of a line, and so on. The meta shortcuts are different from the standard text navigation shortcuts that are tied to the Control key and that work pretty much everywhere in Terminal and often across […]
If you are vi/vim user put set -o vi in your .profile and then you can use vi key bindings to edit the command line. If you also add export EDITOR=vi in .profile you can hit ESC v to edit the long command line in actual vim. This also allows you to easily copy paste long command lines etc.
Vi… Vim… Nano? :P
Still really useful for anyone learning bash though.
A lot of these commands work in normal apps too. Even in this text box in Chrome I can jump around with Control-A and Control-E