Search code examples
bashmacosvireadlinearrow-keys

Fixing <right arrow> in bash vi input mode. Cannot type beyond last character


I'm trying to use vi mode in bash. via the .inputrc (on OSX):

set editing-mode vi

In vi insert mode, the right arrow key moves the cursor to the right, but it stops on the last character in the line. If the cursor is past the end of the line, it moves the cursor to the left. So, in sum, the farthest right you can go is to the last character in the line.

$ cd /usr/locl/bin
# Move the cursor to the middle of the line, and fix something there
$ cd /usr/local/bin
# Now move the cursor back to the end, and write a character (/)
$ cd /usr/local/bi/n

As shown above this means you cannot edit the end of the line without going into command mode (and using 'a').

I found an article which seems to indicate the version of readline/bash might be the problem. However I used brew to upgrade bash (GNU bash, version 4.3.42), and even tried to install and link readline (6.3.8), as recommend by that site. But no luck. Its possible the upgrade was done incorrectly.

This means I'm looking for one of the following:

  • The proper way to upgrade bash and readline in OSX terminal
  • A way to check the versions of bash/readline that OSX is actually using
  • Another fix for this bug (somehow passing in the virtualedit=onemore option in the inputrc)
  • Indications that the latest versions of readline might have re-introduced the bug, and solutions.
  • Also: if theres a similar thing with editrc

Note: I'm looking to make readline in bash act near identical to the default (for others who periodically use my terminal), but allow me to use vim mode. This means I don't need workarounds, but fixes.


Solution

  • Can't you edit .bashrc itself instead to use vi mode? The command set -o vi does it in my case (you are in edit mode initially). Also remove the .inputrc edit as the two may actually interact nefariously afterwards.