10 Keyboard Shortcuts for Text Navigation & Manipulation in the Command Line

Feb 27, 2012 - 4 Comments

Navigate text 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

.

Related articles:

Posted by: William Pearson in Command Line, Mac OS, Tips & Tricks

4 Comments

» Comments RSS Feed

  1. […] 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 […]

  2. Mario says:

    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.

  3. Socapex says:

    Vi… Vim… Nano? :P

    Still really useful for anyone learning bash though.

  4. Parakeet says:

    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

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site