I have vi bindings working in my bash shell using
set -o vi in my .bash_profile. But I can’t seem to get them to work in the
mysql command line client. I only get emacs style bindings. How do you do this?
I also put these lines in my .inputrc, but to with no effect:
set editing-mode vi set keymap vi
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Quick google reveals this… don’t know if it helps.
Copied here for convenience:
Add the following on OS X 10.5:$ cat .editrc bind -v
This will work for OS X 10.4 and
other operating systems:$ cat .inputrc set editing-mode vi
These two files worked on my previous workstation (not sure of the MySQL version (my old job)). I keep my dotFiles in git.
bind -v bind \t rl_complete
.inputrc (several of these may or may-not be needed)
set editing-mode vi set keymap vi set meta-flag on set input-meta on set convert-meta off set output-meta on set bell-style none
Posting these because I couldn’t post them in my comment above.
This doesn’t directly answer your question, but you might want to take a look at the dbext plugin.
This plugin contains functions/mappings/commands to enable Vim to access several databases.
dbext provides a common interface between your editor and a database. If your company/project moves onto a new database platform, there is no need to learn the new databases tools. While editing your SQL (and without leaving Vim) you can execute database commands, run queries, display results, and view database objects. dbext understands various programming languages, and can parse and prompt the user for [host] variables and execute the resulting statement. See below for more details.
A database client inside Vim!
The voted answer is ok, but if you’re encountering problems as it happened to me (I’m currently using Slackware 14.x) then editing /etc/inputrc should be your last hope.
I’ve tested both .inputrc and .editrc on my home, but on my system only editing /etc/inputrc worked.
Also, this is not answer to your question.
You can also use Vimsql like dbext. Vimsql is more convenient way interacting with mysql than
mysql if you love vim key map.