I am using the command line in Emacs mode and would like to move my cursor to a character forwards or backwards. Are there any shortcut keys that I can type to get to that position fast. For e.g., the long command line is

The quick brown fox jumps over the lazy dog

and my cursor is at the first character and want to move to the word over. Right now I have to hit Ctrlx Ctrle to bring up the editor and search and save. Any way to do this in Emacs on the command line itself without shifting to vi?


From the bash manual, on readline commands:

character-search (C-])
A character is read and point is moved to the next occurrence of that character. A negative count searches for previous occurrences.

So, if I had:

$ set -o emacs

Then C-]o will take me to o in -o. You can use counts for the search as well, so M-2 C-] e will take me to emacs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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