1

Ctrl + A and Ctrl + E bring you to the beginning and end of the command line.

How do you jump to the middle? or at least 20 chars or so?

If any of you use bash a lot and type quickly, you end up 'flicking' back and forth from beginning to end quickly.

I'd like to jump really quickly (another control combo w/o loss of Ctrl + A and Ctrl + E ability as one example) to an approximate middle vs holding the Right or Left key down and waiting or needing to jump into vi mode.

3
  • a comment, since I can't find a definitive answer. Check the output of bind -l, and try to find what those those keywords do. There's one 'vi-column' that looks interesting. or try the "forward-word" (ESC-f) backwards-word (ESC-b) tags. Feb 24, 2015 at 21:39
  • @Rich - Thanks! bind 'Control-g:backward-word' and bind 'Control-f:forward-word' approximates the behavior. Kind of: The least typing w/o needing to switch to vi/emacs modes
    – jouell
    Feb 24, 2015 at 22:29
  • Not sure about *nix but on OSX bash, you can use ALT+<- (left arrow) or ALT+-> (right arrow) to move between non-characters/numbers. This works in AWS Linux too. Also don't forget CTRL+u and CTRL+k for delete from cursor to left/right margins respectively and CTRL+w for deleting (backspace) one "word" which is defined as spaces.
    – SaxDaddy
    Feb 26, 2015 at 8:06

3 Answers 3

2

If you set command line editing to vi mode:

set -o vi

Then you can (for example) move position to 20 characters from the start of the line by:

  • pressing ESC key
  • press ^ (to get to start of line)
  • press 20l (moves cursor 20 characters to the right)
2
  • ctrl-a and ctrl-e are emacs/gmacs commands. you're asking them to switch. Feb 24, 2015 at 21:27
  • Yes, this is an answer. I edit my question to get more specific.
    – jouell
    Feb 24, 2015 at 21:52
2

If you are looking for an Emacs Key mode method,

Use alt-# then the command.

For instance, Alt-3 Alt-b will move cursor back three whole words.

Reference

0
0

This answer depends on the nature of the line (i.e. if it's big block of text or individual words) and the terminal emulator used.

If it's individual words, I tend to use ctrl + [left or right arrow key] to hop across words when in mintty.

If in putty, I can do the equivalent with alt+f and alt+b to navigate forwards and backwards across words respectively.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .