3

This is on CentOS 7.2, PHP version 5.6.20. According to readline_info():

<?php
print_r(readline_info());

gives

Array
(
    [line_buffer] =>
    [point] => 0
    [end] => 0
    [library_version] => EditLine wrapper
    [readline_name] =>
    [attempted_completion_over] => 0
)

OK, so readline() is using EditLine. I created a ~/.editrc file with:

bind -v

The permission is 664. I then tried:

<?php
    $line = readline('Enter: ');

But it doesn't seem to read the file, and it's not in Vim mode. Doing an Alt-X followed by a manual command of "bind -v" puts it in Vim mode, so I know it has Vim mode.

I read somewhere else that I might need to manually set the path in an environment variable. So tried setting the full path:

$ export EDITRC=/home/work/.editrc

Still nothing. I've also seen that "export EL_EDITOR=vi" is supposed to work, but still doesn't work.

Does anyone have any way to make this work? I really need Vim mode to work.

Nairebis
  • 283
  • 1
  • 8
  • Another option is to add `set editing-mode vi` to either `/etc/inputrc` or `~/.inputrc` (depending how you are running your PHP) – grochmal Jul 08 '16 at 20:55
  • /etc/inputrc only works with Gnu Readline. I already have it there. – Nairebis Jul 09 '16 at 02:16
  • I was pretty confident that PHP readline always uses GNU readline behind the scenes. It turns out that it can be used with libedit, sorry for my lack of knowledge there. `bind -v` should be the way to do it, there isn't a `/etc` file for libedit. The only thing that I can think of is whether you are 100% sure that you are running you PHP file as the same user that has that `.editrc` in `$HOME`. – grochmal Jul 09 '16 at 02:36
  • I'm running it at the command line, so yes, it's the same user. It just doesn't seem to read the file. Maybe I should file a bug report. – Nairebis Jul 09 '16 at 13:48

0 Answers0