Reputation: 12271
When I run \e
on the command line while logged into the psql
command line tool, my default editor, sublime text, duitifully opens. However, when I type in a query like this:
create table tutorials (
tutorial_id serial primary key,
title text,
author_id integer references authors(author_id)
);
Then hit save and exit, nothing happens! My query is not run. What am I doing wrong? How do I fix this?
Upvotes: 4
Views: 2982
Reputation: 1512
After explicitly setting the PSQL_EDITOR variable it works on macOS Sierra/vim 8/psql 9.4.5
export PSQL_EDITOR="vim"
If you want to make the setting persistent add it to the ~/.profile
PS: Although psql seemed to open vim before setting PSQL_EDITOR I was experiencing the same problem as the OP.
Upvotes: 0
Reputation: 43
Stumbled upon this while experiencing a similar problem, nothing here helped. Eventually tried it with another editor (nano) which seemed to fix it. From there, I nuked my vimrc and added everything back. Strangely enough, that seemed to fix it. Thread here.
Upvotes: 0
Reputation: 41
I had a similar problem until I added the -w switch to export EDITOR.
From http://www.sublimetext.com/docs/3/osx_command_line.html:
Upvotes: 4
Reputation: 36729
After the editor exits, type \p
to see what the editor put back into the query buffer.
Upvotes: 2