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.

I'm using iterm2 under MAC OSX.

I can using "Ctrl+a" move cursor to the head and using "Ctrl+e" move cursor to the end

Is there any hotkey can move cursor to given position?

share|improve this question
    
Specifically, you are using bash in emacs mode. The readline keys are available to you, see linux.die.net/man/3/readline for more details. –  Johnsyweb Mar 4 '13 at 2:56
    
It's useful, thank you. –  hfcorriez Mar 4 '13 at 3:24
add comment

migrated from stackoverflow.com Mar 4 '13 at 10:00

This question came from our site for professional and enthusiast programmers.

2 Answers

Ctrl-]x move to next x
Alt-Ctrl-]x move to prev x


readline doc:

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. 
character-search-backward (M-C-])
    A character is read and point is moved to the previous occurrence of that character. A negative count searches for subsequent occurrences. 
share|improve this answer
add comment

If you like Vi, then you can use it on the command line to do what you want (and much more!):

Add this line to your shell's rc file to turn it on (e.g., .bashrc):

set -o vi # Enable vi key bindings

To activate that setting, source .bashrc (or open a new Terminal window).
Now whenever you want to go to a particular column position on the current line, type:

<Esc>0<col#>l

Esc enters vi command mode on the command line
0 goes to the beginning of the line (column 0)
# is the position you want to go to
l (the letter el) means "move right" the previous number of characters

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.