[SERVER-9140] vi editing mode in mongo shell Created: 27/Mar/13 Updated: 29/Jun/20 Resolved: 29/Jun/20 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 2.4.1 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Minor - P4 |
| Reporter: | Scott Rochford | Assignee: | DO NOT USE - Backlog - Platform Team |
| Resolution: | Duplicate | Votes: | 16 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
n/a |
||
| Attachments: |
|
||||
| Issue Links: |
|
||||
| Participants: | |||||
| Description |
|
Please enable a 'vi' editing mode for the mongo shell. Not all of us are emacs users. There are a few people looking for this feature, cf. discussion in the Mongo Google group here: https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/KccVnEDHt5s |
| Comments |
| Comment by Jessica Sigafoos [ 29/Jun/20 ] |
|
We are not prioritizing this for the new MongoDB Shell at the moment, but it is an interesting usability enhancement that we might consider in the future. We are tracking this idea in our unified feedback portal: https://feedback.mongodb.com/forums/929233-mongodb-shell/suggestions/40781701-vi-mode-for-mongodb-shell. Feel free to vote and comment there. |
| Comment by Guy Hoozdis [ 18/Feb/17 ] |
|
Well done, @Tim! I haven't been using Mongo recently, but I book marked your `mongovi` repo. I'll give it a run in the next few days and see if I can generate any feedback for you. |
| Comment by Tim [ 23/Jan/17 ] |
|
The last couple of months I've been working on a new cli for mongodb written in C. It supports most of all the basic vi-editing and movement commands thanks to editline. I'm currently in the process of creating a package for Debian. In the meantime the source can be found here: https://github.com/timkuijsten/mongovi Any testing and feedback is welcome |
| Comment by Ben Meynell [ 19/Dec/15 ] |
|
Please support vi editing mode in the mongo shell ... |
| Comment by Adrian Lanning [ 09/Nov/14 ] |
|
From the linked google group discussion (2013) it seems the mongodb linenoise lib has diverged significantly from upstream. Anybody know where that is located? (Traveling so can't search db source at the moment.) Perhaps we can submit a newer version of bobrippling's port which supports basic vi bindings to the mongodb version of linenoise. UPDATE: |
| Comment by Michael Jarvis [ 28/Oct/14 ] |
|
Linenoise is the lightweight cross-platform library used to implement Emacs-only line editing. I understand WHY it was done, but since I'm a Linux and Vi fan I would have preferred to have kept readline. |
| Comment by Guy Hoozdis [ 28/Oct/14 ] |
|
On Tue, Oct 28, 2014 at 3:42 PM, Michael Jarvis (JIRA) <jira@mongodb.org> I'm not familiar with Linenoise... I'll take a look at it. To get by I've been using pymongo in an ipython shell. You can make a |
| Comment by Michael Jarvis [ 28/Oct/14 ] |
|
Also, wouldn't it make more sense to implement Vi mode in linenoise? It looks like one person did exactly that, but his pull-request was never accepted. |
| Comment by Michael Jarvis [ 28/Oct/14 ] |
|
I just found this thread because I'm looking for Vi mode as well. Nobody has implemented it yet? |
| Comment by Ryan McKay [ 09/Jun/14 ] |
|
If you are looking to prioritize key bindings, I think a first cut would be Cursor motion keys: w Move to next word 0 Move to the beginning of the line And delete/change: c {motion} delete amount specified by {motion}and also put you in insert mode |
| Comment by Guy Hoozdis [ 29/Jan/14 ] |
|
I'm new here and looking for tasks to tackle as I dig deeper into mongo and its facets. I am passionate about having VIM style:
I totally understand that it would make sense to drop the GNU readline dependency in the name of consistency across platforms. I did glance over the linenoise project and see that it was mentioned in some of the comments here too. I'm not saying that the mongo shell HAS to support VI style key-bindings and I don't mind EMACs style; insofar as it is supported, in the shell. However, I do think that there is something better than exists now. Frankly, that may merely be documentation that directs VI snobs to an alternate CLI or usage scenario. I have used pymongo and iPython as an alternative client / environment- it was alright. If there are still any other users out there that really want to see a solution here, then maybe I can take up some of the leg work and offer a few options (maybe even prototypes) for the dev team to consider. |
| Comment by Tim [ 05/Nov/13 ] |
|
For those that are running Node.js, I've created a small REPL that might be helpfull https://npmjs.org/package/mongovi |
| Comment by John Baber [ 31/May/13 ] |
|
For shells and mysql, it's something you can put in your $HOME/.configfile and could also be issued at the prompt, just as you describe. A command line switch would be unflexible and a little strange, I agree. |
| Comment by Tad Marshall [ 31/May/13 ] |
|
I imagine that a setting (shell command) made in $HOME/.mongorc.js would be the way to enable this feature. Does that sound right? A command line switch (perhaps encoded into an alias) would be an alternative, but seems less flexible. |
| Comment by John Baber [ 30/May/13 ] |
|
http://jbaber.sdf.org/mongodb/ (also attached to this bug) is the table of emacs keybindings from the mongo manual (http://docs.mongodb.org/manual/reference/program/mongo/) augmented by the vi keybindings. This is something mysql, ksh, bash, and lots of other "edit-this-one-line" interfaces do, so it's something users probably expect. |
| Comment by Tad Marshall [ 28/Mar/13 ] |
|
There were a few reasons for switching away from readline; one was to support the same feature set on Windows, Linux and the Mac without requiring users to find third-party libraries. readline is common on Linux, but not on the other platforms. I looked at the pull request and I think it is just a fraction of what you've listed. If you would like to expand your list so that it made sense to a non-vi user, it would be helpful. I understand that there is input mode and command mode and that Esc switches between them, but "hjklfFwWtTIiaArRdDcCb0^BxXypP" is a little terse for a feature request. The interface between dbshell.cpp and linenoise.cpp is pretty similar to what the interface was between dbshell.cpp and readline, so if you wanted to do some C/C++ coding it would not be impossible to create your own version that used readline. The MongoDB version 1.8 source code shows how the readline interface worked. But it's not something that we could use for the mainline codebase because of the issues with the Mac and Windows. |
| Comment by Scott Rochford [ 27/Mar/13 ] |
|
Well, according to Bryan in the linked discussion, at some point the mongo shell switched from using the GNU readline library (which gives us 'vi' support "for free" as it were) to linenoise. What was the motivation for that, out of curiosity? Is it still possible to build the shell with readline instead? Another poster also mentions a patch for 'vi' support but Bryan pointed out that your version of linenoise had deviated from the original release signficantly. However the content of the patch may still be useful. Personally it's the main navigation, history search and recall and editing keys (Esc,hjklfFwWtTIiaArRdDcCb0^BxXypP/) that I miss most, but it would be hard to identify a specific subset that should be included. |
| Comment by Tad Marshall [ 27/Mar/13 ] |
|
Short of cloning the vi mode in bash, is there a set of things that would provide significant value? A list of specific desired features with priorities would make this more approachable. |