0

When using Readline's vi mode in Bash, I can use command v from normal mode, to open the current command line in Vim for editing. However, in this case, Vim does not read my ~/.vimrc file, so none of my own settings work.

This only happens when Vim is called by Readline, not when I run it from the command line.

How can I make Readline to call Vim making it to read .vimrc?

  • What does echo $EDITOR $VISUAL print? – jasonwryan Dec 26 '18 at 22:02
  • @jasonwryan Both are unset. – ARX Dec 26 '18 at 23:06
1

Pressing v when in readline vi command mode calls $EDITOR. If you set it to vim then it will call vim, and vim will read your ~/.vimrc. As you don't have $EDITOR set, it is probably calling vi.

  • Yes Sir, you are right. This is it. Thank you! – ARX Dec 27 '18 at 3:37
-1

readline doesn't "call Vim":

While the Readline library does not have a full set of vi editing functions, it does contain enough to allow simple editing of the line. The Readline vi mode behaves as specified in the POSIX standard.

  • Interestingly, there's a plugin for Vim (used within Vim) which imitates the readline bindings:

This plugins implements a subset of Readline's default keyboard commands to Vim's command-line mode. Mappings available include deletion and navigation by words and other useful stuff.

Because readline "behaves as specified" by POSIX, even if you could persuade it to try to read your .vimrc, that would contain definitions not recognized by readline.

Now... what bash does is separate (at a higher level) than readline. The feature you're interested in is provided by the built-in command fc (that's POSIX as well, although the particular usage you're relying upon does not appear in that page).

  • 1
    I am not referring to editing in bash's command line. I refer to what happens when you press v in normal mode in such command line: a full Vim editor screen opens with your command line, and you are no longer in bash, until you quit Vim and the command that you edited in Vim is immediately executed by bash. That's original Vim, not an emulation by Readline. Try it, press v and see it. – ARX Dec 26 '18 at 23:04
  • In fact, if I do :version in that Vim screen, I get: "Huge version with GTK2-GNOME GUI". – ARX Dec 26 '18 at 23:09
  • 1
    In other words, you're not talking about readline, but a shell alias. – Thomas Dickey Dec 26 '18 at 23:22

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.