Bash – Shell vi mode prints (arg: repetition): How to remove it

bashvi

Whenever you are in vi command mode on the shell and hit a number, like 8, "(arg: 8)" shows at the start of the line. Anyone know how to make it not do that? The moving the line I'm typing is distracting.

Instead of:

(arg: 8) somecmd --itslong --reallylong

This:

somecmd --itslong --reallylong

Best Answer

When you're in command mode in vi (the the actual editor or the Bash mode), pressing digits inputs an argument (hence "arg") that is usually used to set the number of repetitions to perform the following command. To avoid that, you should be in input mode (by pressing i for example) before pressing digits.

Demonstration:

If you're not in vi mode, you can enter it using:

set -o vi

(You can exit vi mode by entering emacs mode: set -o emacs)

Now, in vi input mode type a command like this:

echo abcdefghijk4

You'll notice that you get a digit "4" at the end just as shown above.

Now press Esc. The cursor will move one character to the left and you're now in command mode.

Press a digit, let's say "3". Now you'll see this:

(arg: 3) echo abcdefghijk4

Now press capital X. You should see:

echo abcdefgh4

Three characters ("ijk") have been deleted because you told Readline (Bash's command-line input editor) to "rubout" 3 characters.

Now press i and any digit. The digit was inserted in the command line at the point where the cursor was.

Related Question