7

When I'm in insert mode and I move left from the last cursor position (the empty spot to the right of the last character), then I can't go back to that position anymore. I have to type Esc$a (or replace $ with a bunch of times) to get there. It seems like a lot of extra keystrokes just to, say, go delete the last character (and still be in insert mode).

Is there a better way or should I just use the default emacs mode (even though I don't know a single emacs command)?

4 Answers 4

5

In normal mode you start edit at end of line with Shift+A.

In insert mode you should be able to move to EOL.

In manual:

man readline
/VI Mode bindings<Enter>

As to real/other question, I have to fill in a bit:

$ le eds de x
      ^     ^^
      |     ||
      A     BC

In insert mode do you mean you are not able to move to C, only B from A?

Even with , or End?

So that if you start typing the letters will enter before x?

7
  • 1
    I can't go back to C once I leave that position in insert mode. So if I move all the way to the left and start typing, the x character will always be the last character. Also I don't have a End key (MacBook Pro).
    – hobbes3
    Commented May 7, 2013 at 21:43
  • @hobbes3: Also, do you have an .inputrc file?
    – Runium
    Commented May 7, 2013 at 21:57
  • No, I don't. Is there anything else I should test for? I have noticed that I can get to C on CentOS with set -o vi in my .bashrc. I think this problem is specific to Mac OS X's Terminal.
    – hobbes3
    Commented May 8, 2013 at 4:02
  • 1
    I did that and it's doing the same thing (can't get to C). So weird. It must be a Mac Terminal limitation...
    – hobbes3
    Commented May 9, 2013 at 23:34
  • 2
    @hobbes3: Sounds like a bug then. (Hard to argue for it as a feature.) I posted a ping/question with link here on chat @ apple.stackexchange.com
    – Runium
    Commented May 9, 2013 at 23:50
4

You can just press the End key to get there.

Also, you can use Shift + A (capital A - for append) to put you into Insert Mode at the end of a line.

2

I know this is an old question, but I've been beating my head over this for a few days now and I've finally got it. It turns out the solution is simple: update bash to 4.3. The default bash on Macs (even Yosemite) is 3.2.

Install Homebrew with

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

then do

brew install bash

then change your default shell path (in Terminal Preferences) to

/usr/local/bin/bash

and that's it. Check your bash version with

bash --version

and as an added bonus, you can get mode indicators!

bind 'set show-mode-in-prompt on'

and it will show a + for Insert mode and : for Command mode.

1
  • This had been bugging me for so long - thank you! : ) btw I upgraded with macports - sudo port install bash then set Command in terminal preferences to /opt/local/bin/bash
    – JobJob
    Commented Nov 6, 2016 at 2:26
0

You can use :10000 or more to get to the last line

1
  • :x move to a given line, not within the line.
    – Mat
    Commented May 24, 2013 at 8:13

You must log in to answer this question.

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