How can I go back to the previous whitespace character

R

RickS

Guest
For example, at the command line I have typed:

vi abc-efg_hij.efg

The cursor is at the end of the line. Esc-b takes me to the dot. Another esc-b takes me to the underscore. Another esc-b takes me back to the dash.

Is there something I can press that will take me from the end of the line to the space after "vi"?
 


D

DevynCJohnson

Guest
What shell (csh. bash, tcsh, ...) and terminal (xterm, kterm, ...) are you using?
 
R

RickS

Guest
Did you try it with dashes, underscores and periods, like my "vi abc-efg_hij.efg" example?
 
D

DevynCJohnson

Guest
en_US.UTF-8
Hmmm. Mine too. What distro? I am using Ubuntu 13.10 (Saucy). I think it is some weird bug on your system. What if you tried reinstalling Xterm? Also, try using a different shell, like CSH. Just type "csh", "ksh", "tcsh", "ash", "dash", or what ever else you have. If the cursor moves back in a different shell within Xterm, then it is BASH, if not, then it is Xterm.
 
R

RickS

Guest
Thanks a lot for the help! Maybe somebody else who had the same issue will chime in.
 
D

DevynCJohnson

Guest
Do the arrow keys work in other terminals to move the cursor (like konsole, gnome-terminal, etc.)?
 
K

KenJackson

Guest
Have you set your shellopts to emacs or vi? Execute this command to see:
Code:
set -o | egrep 'emacs|vi'
Emacs is on by default, so if you haven't changed it you can search backward for the space character.
CTRL-R <space>

To continue searching press CTRL-R again. Once you get to where you want to be, you have to stop the search before you start editing. You can do that with cursor movement keys (arrows, CTRL-F, CTRL-B, probably others).

If you're more comfortable with vi than emacs, you might experiment with this. I haven't tried it, but then I'm not comfortable with vi.
Code:
set -o vi
 
M

MikeyD

Guest
In shell:
CTRL -A - Will bring you to the beginning of the line.

In vi:
W and B (as opposed to w and b) will jump between words using only whitespace to differentiate and will ignore dots dashes and the like, which are used by the lower-case equivalents.

Not sure if that works on the command-line though with shellopts set to vi as i've never tried.
Essentially if you just wanted to use Ctrl commands you could use:
Ctrl - A - Beginning of line
Esc - F (or Ctrl - F x2) - Move forward one word (Ctrl F moves one letter)
Ctrl -K - Deletes everything after the cursor
 
Last edited:


Members online


Top