Already asked a question about editing multi-line queries in mysql from under the console. Solution found - vi. But unfortunately, in view of the small experience, I could not complete the idea. The question is: how to get the result back from the vi editor back to the mysql console? Those. I write the request, at the end I specify e, I edit the request ... And then what?

  • For a beginner, vi is complicated, can it be easier for you to use mcedit? Well, if, however, you decide to study vi, then study it at a minimum level, see [en.wikibooks.org/wiki/Vim[[1] [1]: en.wikibooks.org/wiki/Vim - chernomyrdin
  • I then studied, but, I must say, superficially. Actually, I was embarrassed that when editing the file there was no result in the mysql console. And again, I am not resistant to using mcedit, but unfortunately I don’t know how. In principle, I remembered a dozen of the basic commands in vi and that's enough, but if someone tells me how to change the request with the help of mcedit, I will only be happy. - Redlust
  • before starting mysql, do: export EDITOR=/usr/bin/mcedit or write it in the login script, something forever :-) Unfortunately, I don’t know the specifics, but I usually work with a remote machine via ssh -Trunk the tunnels there, for example, then it is convenient to use the GUI pribludy local machine to work with SQL servers and more. - chernomyrdin

1 answer 1

Exit vi with saving:

 <ESC>ZZ 

In mysql, it looks like this:

 mysql> \e -> \g 

Between \e and \g starts vi where you edit the query.