Search code examples
mysqlvimcommand-lineediting

How to navigate the command line in mysql?


I wanted to be able to up-arrow and change stuff in my last command.
I'd like to be able to use vim bindings the way I can at the terminal command with set -o vi

Is there anyway I can set that up for mysql?
I know that I can use edit and then edit it in vim. This is handy but unfortunately is not playing well with then just using up-arrow in mysql> as it bring back the last command but not the last edited command.

I just discovered ctrl-a will go the start of the line. Failing vim key-bindings is there a list of other control keys that I can use to navigate the sql> command line?


Solution

  • If vim bindings aren't an option I have found the following useful:

    ctrl-a start of line
    ctrl-e end-of-line
    ctrl-k delete to end of line (‘kill line’)