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.
-
Just edit the command in vim if you want that extended functionality.– jasonwryanMay 7, 2017 at 1:02
-
2It's free software, so you can add whatever features you feel like. I'm not sure how much work that would be though– FoxMay 7, 2017 at 1:02
-
1The 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.– the_velour_fogMay 7, 2017 at 9:04
1 Answer
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