Documentation Home
MySQL Shell 8.0
Related Documentation Download this Manual
PDF (US Ltr) - 2.1Mb
PDF (A4) - 2.2Mb


5.4 Editing Code

MySQL Shell's\edit command (available from MySQL Shell 8.0.18) opens a command in the default system editor for editing, then presents the edited command in MySQL Shell for execution. The command can also be invoked using the short form\e or key combinationCtrl-X Ctrl-E. If you specify an argument to the command, this text is placed in the editor. If you do not specify an argument, the last command in the MySQL Shell history is placed in the editor.

TheEDITOR andVISUAL environment variables are used to identify the default system editor. If the default system editor cannot be identified from these environment variables, MySQL Shell usesnotepad.exe on Windows andvi on any other platform. Command editing takes place in a temporary file, which MySQL Shell deletes afterwards.

When you have finished editing, you must save the file and close the editor, MySQL Shell then presents your edited text ready for you to execute by pressingEnter, or if you do not want to proceed, to cancel by pressingCtrl-C.

For example, here the user runs the MySQL Shell built-in reportthreads with a custom set of columns, then opens the command in the system editor to add display names for some of the columns:

\show threads --foreground -o tid,cid,user,host,command,state,lastwait,lastwaitl\e\show threads --foreground -o tid=thread_id,cid=conn_id,user,host,command,state,lastwait=last_wait_event,lastwaitl=wait_length