How to get vi keybindings to work in mysql client?

2020-02-17 09:57发布

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

5条回答
Lonely孤独者°
2楼-- · 2020-02-17 10:26

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!

查看更多
欢心
3楼-- · 2020-02-17 10:32

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
查看更多
小情绪 Triste *
4楼-- · 2020-02-17 10:34

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.

查看更多
等我变得足够好
5楼-- · 2020-02-17 10:38

These two files worked on my previous workstation (not sure of the MySQL version (my old job)). I keep my dotFiles in git.

.editrc 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.

查看更多
再贱就再见
6楼-- · 2020-02-17 10:43

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.

查看更多
登录 后发表回答