Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This question already has an answer here:

I usually use Linux, no expert at all (very far from it) but I use it daily.

Sometimes I find myself using (someone else's) Mac and typing commands into a Terminal.

In Linux, I can use Ctrl+Left and Ctrl+Right to move backward or forward in the current line one word at a time (as in most text editors btw). If I try to do that in Mac OS, it switches workspaces, or brings to front another window, or some irritating thing like that. I think I tried both the Command and the Ctrl (proper) key.

Is there a different key combination for that in Mac OS? At the end I find myself holding down the arrow kay to move one character at a time, which in Mac OS for some reason is like 10 times slower than in Linux and Windows.

share|improve this question

marked as duplicate by gronostaj, Kevin Panko, ukanth, Journeyman Geek Sep 5 '14 at 2:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 3 down vote accepted

Opt-B moves one word backwards, Opt-F one word forward. These are emacs keybindings your shell (bash) supports and has enabled by default. You need to have checked the Use option as meta key preference (pictured below).


Additionally, in your Terminal's profile settings, you can assign special escape sequences to e.g. Opt-Left and Opt-Right to make the familiar keyboard shortcuts work in Terminal, like these:

enter image description here

enter image description here

Use \033[5D to move left, and \033[5C to move right.

share|improve this answer
2  
I found that with iTerm, it was easier to just add "\e[1;9D": backward-word and "\e[1;9C": forward-word to ~/.inputrc (or whatever the read command shows for the keyboard shortcuts you want to use. I did this because using option as the meta key is not always preferable (e.g. German keyboard where the ~ maps to option-n). –  slhck Jan 24 '12 at 13:18

If you are using iTerm, and want the Linux like Crtl + L / R mapping, slhck's suggestion works well.

Just add:

"\e[1;5D": backward-word
"\e[1;5C": forward-word

to ~/.inputrc (create the file, if it does not exist), for Ctrl - left, and Ctrl - right, respectively.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.