diff -uNr libedit-20170329-3.1/src/vi.c libedit-20170329-3.1.mod/src/vi.c
--- libedit-20170329-3.1/src/vi.c	2017-03-29 21:08:21.000000000 +0300
+++ libedit-20170329-3.1.mod/src/vi.c	2018-06-19 17:16:24.144390787 +0300
@@ -1004,7 +1004,7 @@
 	pid_t pid;
 	ssize_t st;
 	int status;
-	char tempfile[] = "/tmp/histedit.XXXXXXXXXX";
+	char tempfile[] = "@TERMUX_PREFIX@/tmp/histedit.XXXXXXXXXX";
 	char *cp = NULL;
 	size_t len;
 	wchar_t *line = NULL;
