Vi mode for MongoDB Shell
Please enable a 'vi' editing mode for the mongo shell.
- Similar to vi mode in bash
- Similar to https://www.npmjs.com/package/mongovi
A first cut of key bindings would be:
Basic command mode/editing mode toggling:
i Insert before cursor
Esc Toggle to command mode
Cursor motion keys:
h Move left
j Move down
k Move up
l Move right
w Move to next word
b Move to the beginning of the word
0 Move to the beginning of the line
$ Move to the end of the line
And delete/change:
x delete next character to the right
d
{motion} delete amount specified by {motion}
c
{motion} delete amount specified by {motion}
and also put you in insert mode
-
AdminGaurab (Admin, MongoDB) commented
You can use an external editor (see docs: https://www.mongodb.com/docs/mongodb-shell/reference/editor-mode/#using-an-external-editor).
For vi specifically, you can run `config.set( "editor", "vi" )` in mongosh and launch a vi editor by subsequently running `edit` in mongosh.
-
yf commented
Looking forward to external editor support by EDITOR environment.
-
AdminMassimiliano (Admin, MongoDB) commented
The new MongoDB shell (built on the node REPL) includes an editor mode (activated with .editor) that provides multiline editing capabilities.
Additionally, in the future, we will support using an external editor by setting the EDITOR environment variable similarly to how mongo does it.
vi mode directly in the REPL is not something we will prioritize now but we'll definitely keep it in mind as a future usability improvement.