2

As noted in this question, you cannot use the ci" (or ci', ci{, ci<, etc.) feature of vim in bash's vi-mode because this feature is from vim, not the original vi. However, is there a way to add this feature anyway? If so, how? I use this all the time, and it would be extremely useful to have on the command line.

3
  • Just edit the command in vim if you want that extended functionality.
    – jasonwryan
    May 7, 2017 at 1:02
  • 2
    It's free software, so you can add whatever features you feel like. I'm not sure how much work that would be though
    – Fox
    May 7, 2017 at 1:02
  • 1
    The vim feature you are describing is called "text objects". There are shells other than bash that have more focus of these fancy shell features. for example what you are asking for is possible using zsh and this opp.zsh plugin. Note: according to the opp.zsh readme, this functionality is now builtin to the zsh versions 5.08 and greater. May 7, 2017 at 9:04

1 Answer 1

2

No, that would require an extension in Bash itself. As it always speaks of "vi-editing" (not Vim), this is unlikely to happen. Just imagine all the other nice Vim features users would request :-)

But if you have set -o vi in Bash, and $EDITOR or $VISUAL set to our lovely Vim, you can edit the current command-line inside a fresh Vim instance via Esc V.

If you additional want an "insert-mode" shortcut (like :help c_CTRL-F in Vim to open the command-line window), you can put the following into your ~/.inputrc:

$if Bash
# Ctrl-F        Invoke the editor on the current command line.
#           Like c_CTRL-F in Vim.
#           Related: fc does the same for the _previous_ command.
Control-f: edit-and-execute-command
$endif

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.