Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vi mode missing #65

Closed
arael opened this issue Jun 7, 2012 · 85 comments
Closed

vi mode missing #65

arael opened this issue Jun 7, 2012 · 85 comments

Comments

@arael
Copy link

@arael arael commented Jun 7, 2012

Maybe I overlooked in the documentation but it seems to me that the vi mode is missing. I think that fish shell is awesome but without the vi mode I cannot use it as my everyday shell. Is there any way to enable the vi mode in fish right now?

Maybe it is possible to achieve this through the configuration somehow although I have doubts. It is more likely that this is a missing feature.

Thank you very much for all your work.

@jonsterling
Copy link

@jonsterling jonsterling commented Jun 7, 2012

I think this is on the list of planned features somewhere…

@SebastianThorn
Copy link

@SebastianThorn SebastianThorn commented Jun 8, 2012

what is vi mode suppose to do?

@arael
Copy link
Author

@arael arael commented Jun 9, 2012

Emacs is a powerful text editing program. Usually the default for all shells is the emacs mode. This means that the command line editing can be performed by using emacs shortcuts. So Ctrl-a puts the cursor on the beginning of the line and Ctrl-e on the end of the line. Alt-f advances the cursor forward word by word while Alt-b works in reverse. Alt-d cuts a word and Ctrl-y pastes it etc. If you know emacs you can use most of its keyboard shortcuts to edit your command line.

Vi/Vim is also a text editor program. The vi mode has its own set of shortcuts and it is modal. There is the normal or command mode and the insert mode. The command mode is used to browse the history and perform command line editing just like in vi. The insert mode is meant to insert text. So in the normal mode pressing 0 puts the cursor on the beginning of the line while $ puts it at the end. You can advance between words by pressing w or e and cut words by pressing cw (change word). Pressing p pastes the word back etc. The vi mode is very useful for people using vi/vim as their default editor. It is quite efficient if you know vi.

If you are interested I suggest you to search on web more info about the subject. Knowing how to move efficiently on your command line is useful and interesting and most importantly more productive.

@jonsterling
Copy link

@jonsterling jonsterling commented Jun 9, 2012

That was a hell of an answer! Cheers.

Sent from my iPhone

On Jun 9, 2012, at 1:56 AM, Goran Josicreply@reply.github.com wrote:

Emacs is a powerful text editing program. Usually the default for all shells is the emacs mode. This means that the command line editing can be performed by using emacs shortcuts. So Ctrl-a puts the cursor on the beginning of the line and Ctrl-e on the end of the line. Alt-f advances the cursor forward word by word while Alt-b works in reverse. Alt-d cuts a word and Ctrl-y pastes it etc. If you know emacs you can use most of its keyboard shortcuts to edit your command line.

Vi/Vim is also a text editor program. The vi mode has its own set of shortcuts and it is modal. There is the normal or command mode and the insert mode. The command mode is used to browse the history and perform command line editing just like in vi. The insert mode is meant to insert text. So in the normal mode pressing 0 puts the cursor on the beginning of the line while $ puts it at the end. You can advance between words by pressing w or e and cut words by pressing cw (change word). Pressing p pastes the word back etc. The vi mode is very useful for people using vi/vim as their default editor. It is quite efficient if you know vi.

If you are interested I suggest you to search on web more info about the subject. Knowing how to move efficiently on your command line is useful and interesting and most importantly more productive.


Reply to this email directly or view it on GitHub:
https://github.com/ridiculousfish/fishfish/issues/65#issuecomment-6218113

@arael
Copy link
Author

@arael arael commented Jun 9, 2012

=)

@SebastianThorn
Copy link

@SebastianThorn SebastianThorn commented Jun 9, 2012

okey, been using emacs all my life and i never thought of the vi/m isers around the world ;)

@silenc3r
Copy link

@silenc3r silenc3r commented Jun 9, 2012

If you plan to make vi mode, please make it display current mode (command/insert/visual). As much as I like vim I find vi mode in shell extremly annoying and unusable since I never know which mode I am in.

@arael
Copy link
Author

@arael arael commented Jun 10, 2012

@SebastianThorn We are out there brother. ;)

@silenc3r That is an excellent suggestion. I highly second that.
In bash I have the same problem. Pressing i first has become an habit of mine. This would be very useful to have in fish.

@paidhi
Copy link

@paidhi paidhi commented Jun 16, 2012

I second that.
The missing vi-mode was the one thing keeping me from using the original fish shell.
"Complete vi-mode key bindings" was in the manual section of "Missing features" forever.

@kalikiana
Copy link

@kalikiana kalikiana commented Jun 28, 2012

There's an interesting implementation of this being developed on the mailing list: http://sourceforge.net/mailarchive/message.php?msg_id=29431816

@arael
Copy link
Author

@arael arael commented Jun 28, 2012

It is not complete yet but it is functional actually.

@JeanMertz
Copy link

@JeanMertz JeanMertz commented Nov 18, 2012

@kalikiana Thank you for that link. I got it working and it looks nice. However, it's not on-par with the zsh vi-mode yet.

It also seems pretty slow. Actions like jump back one word have a lag of a few hundred milliseconds.

This script surely seems like a good start, but with the slowness I guess it can become somewhat annoying if you use it on a daily basis.

@hauleth
Copy link
Contributor

@hauleth hauleth commented Nov 20, 2012

👍

@davidrivers
Copy link

@davidrivers davidrivers commented Jan 2, 2013

zomg +1

@amitkot
Copy link

@amitkot amitkot commented Jan 7, 2013

+1

@nocksock
Copy link

@nocksock nocksock commented Feb 18, 2013

How's the status on this?

@arael
Copy link
Author

@arael arael commented Feb 18, 2013

Well, there is nothing in the release notes yet so I guess the vi-mode is still missing. You can check here:
http://www.ridiculousfish.com/shell/release_notes.html

@ridiculousfish
Copy link
Member

@ridiculousfish ridiculousfish commented Feb 18, 2013

I'm not aware of any work being done on this, though obviously it's highly desired.

I'd like to do it but I'm not a vi user, so it'll take me a while to ramp up. On the other hand it makes an excellent excuse to learn.

@JeanMertz
Copy link

@JeanMertz JeanMertz commented Feb 18, 2013

I would love to see this become a reality!

On Mon, Feb 18, 2013 at 10:09 PM, ridiculousfish notifications@github.com
wrote:

I'm not aware of any work being done on this, though obviously it's highly desired.

I'd like to do it but I'm not a vi user, so it'll take me a while to ramp up. On the other hand it makes an excellent excuse to learn.

Reply to this email directly or view it on GitHub:
#65 (comment)

@maxfl
Copy link
Contributor

@maxfl maxfl commented Feb 19, 2013

There is a partial implementation of vi-mode here. It's not updated currently.
https://raw.github.com/DarkStarSword/junk/master/vi-mode.fish

@ridiculousfish, I think one of the main obstacles which makes it difficult to introduce a vi-mode is the lack of bind modes: the ability to quickly switch a current set of bound keys to another one is highly desirable. Introducing it will greatly simplify extension of vi-mode bindings by the ordinary users.
I mean something like this:

bind -m vi-normal i 'some action' # for the key 'i' to work only in vi-normal mode
bind -m vi-normal # to switch to the vi-normal mode, where only 'i' key is defined

There was a message by Ian Munsie (the author of the vi-mode) on a fish shell mailing list with a feature request he needed for his implementation of the vim mode. They might be still relevant:

For the suggestion of an option to catch the next symbol, I think that bind '' func would be enough if func can determine which key was pressed. Passing the key in as a parameter would make sense, but would likely break existing code, so perhaps a special variable could be introduced for this purpose? If there is already a way to do this that I've missed let me know, but as far as I can tell self-insert is the only function that can do this.

There is still also the caveat that if '' is not bound to self-insert then commandline -f repaint doesn't repaint the prompt, which would need to be fixed before I could make use of it.

Another feature I'd like is a way to temporarily suppress the auto-suggestion feature. It's a bit out of place in vi normal mode, and can obscure the results of the change-case commands if a suggestion is already being displayed. I see there is already a suppress_autosuggestion variable which is set when pressing backspace - it would be great if I could set that with something like commandline -f suppress_autosuggestion when leaving insert mode. I personally don't mind whether I have to explicitly re-enable it or just wait until it is implicitly re-enabled next time a character is
inserted.

Cheers,
-Ian

@trevor
Copy link

@trevor trevor commented May 8, 2013

👍

@nagisa
Copy link
Contributor

@nagisa nagisa commented May 9, 2013

I'm waiting for this too.

@vially
Copy link
Contributor

@vially vially commented May 15, 2013

👍

@oelmekki
Copy link

@oelmekki oelmekki commented May 17, 2013

+1

I've just discovered fish and it seems great. But using bash in vi-mode for years make it a deal breaker for me.

Nobody mentioned it, but vi-mode is not a bash or zsh feature (provided they did not rewrote it totally), it's a readline feature : http://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC22

I see a few readline references in codebase, but mostly about a "inject readline function" option, so I'm not sure if fish use readline. If it does, I suppose we could have a basic support by switching its mode to vi on fish init. I'm afraid it's not the case, though, as setting set editing-mode vi in ~/.inputrc does not affect fish.

@trevor
Copy link

@trevor trevor commented May 17, 2013

good find @oelmekki, all new to me

@dag
Copy link
Contributor

@dag dag commented May 17, 2013

I'm not convinced vi-style really works well for a command line, even though you could consider me a hardcore Vim user. It's really shitty in readline, and actually even in Vim I use vim-rsi to get the default readline bindings in Insert and Command mode, because they're just better for single-line input with minor editing, which is what you tend to do in a shell. However, fish actually makes multi-line commands more useful, so things might be different in fish. If we do this in fish, I think it's important that we avoid the limitations of vi-mode in readline, which for me means making it clear which mode you're in (such as by putting it in the prompt and repainting it on mode changes, and/or in the terminal title) and that it supports Vim's features for multi-line editing and the operator-pending mode. That means things like ciw and da( should work and that jk moves between lines, etc. None of those work or do the right thing in readline's vi-mode. Proper support for repeat (with .) is also rather telling about the quality of a vim imitation.

However I'm not sure if having two completely different key bindings supported is in line with fish's design philosophy. Might be fine to extend bind with the necessary features to make this possible in a third-party script though.

@oelmekki
Copy link

@oelmekki oelmekki commented May 17, 2013

@dag Well, your proposition is surely interesting, and I would be glad if this happens. But just to be clear, I would love to have an implementation as "shitty" as readline's one instead of nothing, if your view of correct implementation happens to be too difficult to realize.

@arael
Copy link
Author

@arael arael commented May 17, 2013

same here. I really like the suggestions dag made and it would be great to have that implemented but I would settle with the readline support gladly.

@dag
Copy link
Contributor

@dag dag commented May 17, 2013

I sympathize but I think that way lies zsh: there's a feature or configuration option for everything, but nothing feels quite complete or thought out. fish on the other hand tries hard to not make anything an option (but of course it's unavoidable) and to prefer quality features over quantity. But at the same time I think that fish tries to be highly customizable, which isn't the same thing as configurable. What I mean is that it provides the tools to let you easily script any feature you want. Take for instance my recent comment over in #128. That's what I'm after with extending bind without adding a vi mode option in fish core.

@Slava
Copy link

@Slava Slava commented Nov 12, 2013

@trevor

Hi, can you tell me more on what you mean here?

My use-case:

  1. I switch back to some tab or screen tab or just different terminal window
  2. I don't remember (and I can't) what was the last state of the command line (normal or insert)
  3. To switch to vim (edit current line in vim) I need to press 'v' from the normal mode
  4. Since I don't know what is the current mode, I would tap ESC and then press 'v' but it is not better than just switching to normal mode every time (exactly the thing that annoys me).
@Gonzih
Copy link
Contributor

@Gonzih Gonzih commented Dec 5, 2013

Any changes on that question? Would love to use vi mode in fish!

@pirj
Copy link

@pirj pirj commented Dec 5, 2013

Bottom line:
Issue reopened.
There are couple different ways on how to implement this.
Milestone is fish-future which means:

These are bugs that are not targeted for an upcoming release. If you can provide a fix for a bug in this milestone, we'll generally accept it for the next release even if the bug is not in the release.

+1's do not work.
Please help if you're a good C coder and can submit a patch.

@xfix
Copy link
Member

@xfix xfix commented Dec 5, 2013

@pirj: I'm going to confirm this. Make a good patch, submit it, and it will be accepted for next fish shell release. fish-future is intentional - it isn't high priority (because it's relatively complex), but that doesn't mean developers don't want this feature. The patch implementing bind modes, or something like that would be preferred.

@syl20bnr
Copy link

@syl20bnr syl20bnr commented Jan 14, 2014

For those who cannot wait the official vi-mode for fish I submitted a vi-mode plugin into the oh-my-fish repo: bpinto/oh-my-fish#107
The vi key bindings support is basic but I plan to improve it a bit. See the README for more info.

@furunkel
Copy link
Contributor

@furunkel furunkel commented Jan 18, 2014

You might be interested in this: #1218.

keith added a commit to keith/dotfiles that referenced this issue Feb 17, 2014
Probably won't ever use fish, there are still some massive features
missing fish-shell/fish-shell#165
fish-shell/fish-shell#65
@roytruelove
Copy link

@roytruelove roytruelove commented Feb 25, 2014

+1

1 similar comment
@vikstrous
Copy link

@vikstrous vikstrous commented Mar 20, 2014

+1

@xfix
Copy link
Member

@xfix xfix commented Apr 1, 2014

Fixed by applying #1218. This is not an April Fools' joke. Now the +1 flood can stop. If you want to test new vi mode, download the newest master, and run fish_vi_key_bindings. You can also use fish_vi_prompt to see the current status (or use $fish_bind_mode directly). There are still some issues, like #1387, but the basic support for vi bindings now exists.

@furunkel: Feel free to apply for $200 at https://www.bountysource.com/issues/986070-vi-mode/bounties. You probably are aware of this bounty, if you read this topic, but I mention this just in case. I believe your patch wasn't easy to make anyway, so you definitely deserve this bounty from the community.

@xfix xfix closed this Apr 1, 2014
@arael
Copy link
Author

@arael arael commented Apr 1, 2014

Thank you very much!

@oelmekki
Copy link

@oelmekki oelmekki commented Apr 1, 2014

Awesome, thanks !

Now the +1 flood can stop.

By the way, if this annoys you, make sure to report it to github. A +1
feature on issues is long overdue, and all popular open source
repositories are annoyed by this.

@jstrater
Copy link

@jstrater jstrater commented Apr 1, 2014

Thank you, @furunkel!

@catalan42
Copy link
Contributor

@catalan42 catalan42 commented Apr 18, 2014

OMG this is soooooo cool! And just in time, too!

@rappo
Copy link

@rappo rappo commented Oct 15, 2014

The $200 bounty that was posted on this issue waiting to be claimed, @furunkel :)
https://www.bountysource.com/issues/986070-vi-mode-missing/developers

@Gonzih
Copy link
Contributor

@Gonzih Gonzih commented Nov 6, 2014

Is there any information on when this feature will be included in release? I don't see it in 2.1.1.

@zanchey
Copy link
Member

@zanchey zanchey commented Nov 6, 2014

It will be in the next minor release (2.2.0).

@Gonzih
Copy link
Contributor

@Gonzih Gonzih commented Apr 10, 2015

Ugh, I just updated fish nightly on my machine to the version fish, version 2.1.2-1247-gfbe28fd and now after command execution vim mode always jumps in to insert mode. I have hard times understanding what has changed. Any tips? Thank you.

@vially
Copy link
Contributor

@vially vially commented Apr 10, 2015

Most probably this has changed.

@Gonzih
Copy link
Contributor

@Gonzih Gonzih commented Apr 10, 2015

Ok, it's related to the #1933 issue. I actually don't like this change, feels weird. Not sure that blindly mimicking vim mode from zsh is a good idea on it's own. I will erase this binding in my configuration, not a problem.

Thanks for pointing this out, @vially

@ridiculousfish
Copy link
Member

@ridiculousfish ridiculousfish commented Apr 10, 2015

How do other vi-mode users feel about switching to insert mode after command execution? I merged that because it's what bash and zsh do, so I assumed it would feel natural, but maybe I was mistaken.

@floam floam added the vi-mode label Jul 3, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.