diff --git a/contrib/libedit/vi.c b/contrib/libedit/vi.c index 010616cdf1d..e7bf188b8b8 100644 --- a/contrib/libedit/vi.c +++ b/contrib/libedit/vi.c @@ -1008,12 +1008,15 @@ vi_histedit(EditLine *el, wint_t c __attribute__((__unused__))) char *cp = NULL; size_t len; wchar_t *line = NULL; + const char *editor; if (el->el_state.doingarg) { if (vi_to_history_line(el, 0) == CC_ERROR) return CC_ERROR; } + if ((editor = getenv("EDITOR")) == NULL) + editor = "vi"; fd = mkstemp(tempfile); if (fd < 0) return CC_ERROR; @@ -1038,7 +1041,7 @@ vi_histedit(EditLine *el, wint_t c __attribute__((__unused__))) goto error; case 0: close(fd); - execlp("vi", "vi", tempfile, (char *)NULL); + execlp(editor, editor, tempfile, (char *)NULL); exit(0); /*NOTREACHED*/ default: