You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This concerns Alt-Left/Right and Alt-Backspace.
The recognition of a word on the command line has been changed to be more permissive. For example this is considered as one word by fish:
firstword|secondword;
hence Alt-Backspace deletes it by one stroke.
Also I remember "file.ext" being two words, now it is considered as one. I would like having the former behaviour again.
Also a bug with Alt-Backspace:
I have this on the command line: "locate completions" and the cursor stands on the c of "completions". When I hit Alt-Backspace, the word "locate" will be correctly deleted, but also the first character of "completions", leaving me with "ompletions".
there's at least three definitons of word boundaries to think about: emacs, vi, and unicode… presumably users of emacs keybindings would prefer emacs words, and similarly for vi? unicode always sounds nice, but I'm not sure it's necessarily a good idea for the command-line...
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/384#issuecomment-10366732.
Well, Emacs speakers will really expect alt+b to stop in the underscore in ls foo/my_dir[alt+b], whereas vi natives will really expect esc+b to stop on slash, and esc+shift+B to stop on space (and emacs+vi bilinguals like me will expect it to depend on keybinding). This is how bash does it, depending on whether it's in vi or emacs mode.
However, I agree that one could argue that both emacs and vim are living fossils, and that the "friendly interactive" shell could well choose more sensible word boundaries for commandline arguments. I'm just reviewing all the options.
I also have problems with new behaviour. @stestagg is right about the context. I do not want word symbols to be like in emacs or like in vim. You want them to be comfortable for the commandline editing: First of all you want cursor to stop on space,/,=,-,.,>,^ and possibly _, because _ is often used as inner separator.
The following change makes word movement stop at separator boundaries: |, ;, <, etc. It also fixes the issue where the character under the cursor is deleted as well.
My thinking is that for command line shells, 'words' are either path components, which are separated by /, or tokens, which are separated by whitespace and characters like |, ;, <. However I am interested in hearing more discussion on the issue.
Work with option arguments: change --option=arg1 to --option=arg2, i.e. it word is divided by '='
Sometimes it also useful on changing long options:
--long-option1 -> --long-option2
which is possible when words are separated by '-'.
Changing the file extension (very often issue). One could think of file extension as path component. i.e. stop on '.'.
Work with comma-separated list. Stop on ','. {foo,bar,bar} is now a single word.
Work with long filenames with underscores. A lot of people use underscores to add some suffixes to the filename and it's often needed to change only a suffix. It would be very helpful to stop on underscore.
Quotes: "$foo"bar is considered to be a single word now. To change bar comfortably one should introduce '"' as word separator.
Brackets/parentheses: these are all words now $var[1], text(echo), text{text}.
The difference with for example --option=argument1 and --option=argument2 is:
Either you press ^W twice/three times to delete the whole token, but you are able to delete argument1 with single ^W.
Either you can delete the whole token with a single ^W, but have to press backspace 9 times or to hold it for some time to delete the argument1. It works with all the examples, one can save several ^W/AltLeft/AltRight key pressures by killing ability to save much more backspace/left/right.
@maxfl : Notice though that Emacs word separation (and therefore bash's default) stops in all the cases you give (namely [ "'/=-.>^_,]). So, with the cursor following 'r', meta-backspace in emacs/bash will delete the three characters "bar" in all of the following:
@leoboiko, I'm pretty aware about it. The same will do vim and and most of the other sane editors.
I'm almost sure that we can simply copy emacs's/bash/vim behavior without any problems. But there is nothing wrong in attempt to understand which word separators we want to use and why.
@ridiculousfish It is much better now, thank you. But please, pretty please, could you make it so that it would stop at dashes and periods as well? For example deleting a file extension with alt-backspace is very common for me and is natural in any editor I use.
By the way a possible solution for this is to introduce a variable holding word separators. It is not very fishy, I know. But I find this acceptable because it generally doesn't affect fish performance, but only user interaction. In this way it would be comparable to the color variables.
Another argument for this is that both zsh and bash stop at ._- while fish doesn't.
A dot . it very handy when you're just changing a file extensions, or part of a URL.
Dashes - and underscores _ on the other hand are often used for kind of namespacing things and in URLs. For example you might have something like some-app-with-very-long-name-1.example.com. It is impossible to navigate parts of the URL with M-b and M-f and you basically have to use arrows to find the right place.
Another example might be git branches, where you can have hotfix-hamburger-issue and you want to change it to hotfix-cheesburger-issue. In zsh you can press M-b M-b M-d and end up with hotfix-<cursor here>-issue. But in fish it means you have to use arrows for this.
In VIM you can easilly do something like F-cT-, or F_cT_ in case of underscores (because b in VIM would also jump over the whole thing in case of underscores). So having it behave the same way as VIM does also makes no sense, because it is a completely different context.
M-d also behaves the same way, so that it is easy to use M-b to jump in between of somewhere, and then just forward delete a part of something with M-d. For example if you have
and from that point if you try M-backspace, you'll lose the whole expression
ssh <cursor here>var/apps
There are a lot of times when I need to just delete a part of some command and I have to use arrow keys and keep tapping C-d or backspace so delete a word, because M-d would delete the whole command.
@pgan002 different behaviour for different keys is the default how all of the other shells behave. That does not mean it is more complicated, because everyone who has been using emacs-like keybindings in shells is used to these.
@darthdeus Thank you for the explanation - I was unaware of the difference between C-w and M-backspace.
I see no reason to expect that C-w and M-backspace, being totally different key combinations, should have the same behavior; in fact doing so would seem like needless duplication. Realizing that other shells have different behavior for C-w and M-backspace makes me drop any objection to different word navigation, so I'll restore the behavior of stopping on punctuation for M-f, M-b, and M-backspace, and we can discuss further from there.
Having the C-w behavior as a second method of deleting has two advantages that I can think of:
It is more flexible
Users of other shells won't miss it
It has several disadvantages:
It is not orthogonal
One of the methods is not very discoverable once you know the other (as illustrated by ridiculousfish)
If you do discover it, it can be confusing. Also (as far as I can see) there is no corresponding method of navigating.
It is more complicated to explain
It impedes habituation because the user has to think about which method to use
I think advantage 1 is minor. I expect most users would naturally habituate to using one method because otherwise they would have to think about which method is appropriate every time they want to delete. This is a big reason to strive for orthogonality in general.
Advantage 2 is minor because:
a. Getting used to using the only way to do something is relatively easy, especially if it is the way you are already used to using in GUI text editors
b. Being like other shells is not a high priority for Fish.
Sure, some of the disadvantages are minor too. But on the whole, I feel the arguments are strong against having an additional deletion behavior.
By same logic, there is no need to have backspace and M-backspace, as the
user will have to think whether to remove a character or a word every time,
let's have only backspace :-)
Obviously it's now missing 'kill-path-component' in addition to 'backward-kill-path-component'.
There is also an open question: what should be used for partial auto-completion by AltF: word separator or path separator? I myself have not decided yet, so I just raise the question.
Activity
melissaboiko commentedon Nov 14, 2012
there's at least three definitons of word boundaries to think about: emacs, vi, and unicode… presumably users of emacs keybindings would prefer emacs words, and similarly for vi? unicode always sounds nice, but I'm not sure it's necessarily a good idea for the command-line...
SanskritFritz commentedon Nov 14, 2012
I just want the old behaviour back.
stestagg commentedon Nov 14, 2012
I think that word boundary definitions are too context sensitive to try to
group them into broad categories.
The fish word boundaries should be set to those that are natural to people
working with argument lists that are commonly paths.
Steve
On Wed, Nov 14, 2012 at 1:58 PM, SanskritFritz [email protected]:
melissaboiko commentedon Nov 14, 2012
Well, Emacs speakers will really expect alt+b to stop in the underscore in
ls foo/my_dir[alt+b], whereas vi natives will really expect esc+b to stop on slash, and esc+shift+B to stop on space (and emacs+vi bilinguals like me will expect it to depend on keybinding). This is how bash does it, depending on whether it's in vi or emacs mode.However, I agree that one could argue that both emacs and vim are living fossils, and that the "friendly interactive" shell could well choose more sensible word boundaries for commandline arguments. I'm just reviewing all the options.
maxfl commentedon Nov 15, 2012
I also have problems with new behaviour.
@stestagg is right about the context. I do not want word symbols to be like in emacs or like in vim. You want them to be comfortable for the commandline editing: First of all you want cursor to stop on space,/,=,-,.,>,^ and possibly _, because _ is often used as inner separator.
SanskritFritz commentedon Nov 15, 2012
Honestly I think we should find out what commit caused the change and revert that part.
maxfl commentedon Nov 16, 2012
It seems that behaviour's changed after commit: 8eb53ea
commit 8eb53ea
Author: ridiculousfish [email protected]
Date: Thu Oct 4 14:35:03 2012 -0700
ridiculousfish commentedon Nov 19, 2012
The following change makes word movement stop at separator boundaries: |, ;, <, etc. It also fixes the issue where the character under the cursor is deleted as well.
My thinking is that for command line shells, 'words' are either path components, which are separated by /, or tokens, which are separated by whitespace and characters like |, ;, <. However I am interested in hearing more discussion on the issue.
To [email protected]:fish-shell/fish-shell.git
2667868..44ce3e6 master -> master
maxfl commentedon Nov 19, 2012
It also should be comfortable to:
--long-option1 -> --long-option2
which is possible when words are separated by '-'.
The difference with for example --option=argument1 and --option=argument2 is:
Either you press ^W twice/three times to delete the whole token, but you are able to delete argument1 with single ^W.
Either you can delete the whole token with a single ^W, but have to press backspace 9 times or to hold it for some time to delete the argument1. It works with all the examples, one can save several ^W/AltLeft/AltRight key pressures by killing ability to save much more backspace/left/right.
melissaboiko commentedon Nov 19, 2012
@maxfl : Notice though that Emacs word separation (and therefore bash's default) stops in all the cases you give (namely [ "'/=-.>^_,]). So, with the cursor following 'r', meta-backspace in emacs/bash will delete the three characters "bar" in all of the following:
maxfl commentedon Nov 19, 2012
@leoboiko, I'm pretty aware about it. The same will do vim and and most of the other sane editors.
I'm almost sure that we can simply copy emacs's/bash/vim behavior without any problems. But there is nothing wrong in attempt to understand which word separators we want to use and why.
SanskritFritz commentedon Nov 20, 2012
@ridiculousfish It is much better now, thank you. But please, pretty please, could you make it so that it would stop at dashes and periods as well? For example deleting a file extension with alt-backspace is very common for me and is natural in any editor I use.
maxfl commentedon Nov 25, 2012
By the way a possible solution for this is to introduce a variable holding word separators. It is not very fishy, I know. But I find this acceptable because it generally doesn't affect fish performance, but only user interaction. In this way it would be comparable to the color variables.
darthdeus commentedon Dec 14, 2012
Another argument for this is that both
zshandbashstop at._-while fish doesn't.A dot
.it very handy when you're just changing a file extensions, or part of a URL.Dashes
-and underscores_on the other hand are often used for kind of namespacing things and in URLs. For example you might have something likesome-app-with-very-long-name-1.example.com. It is impossible to navigate parts of the URL withM-bandM-fand you basically have to use arrows to find the right place.Another example might be git branches, where you can have
hotfix-hamburger-issueand you want to change it tohotfix-cheesburger-issue. Inzshyou can pressM-b M-b M-dand end up withhotfix-<cursor here>-issue. But in fish it means you have to use arrows for this.In VIM you can easilly do something like
F-cT-, orF_cT_in case of underscores (becausebin VIM would also jump over the whole thing in case of underscores). So having it behave the same way as VIM does also makes no sense, because it is a completely different context.SanskritFritz commentedon Dec 14, 2012
I fully agree with @darthdeus here. Please, pretty please make fish stop again at periods and dashes and stuff.
13 remaining items
darthdeus commentedon Dec 20, 2012
@ridiculousfish C-w is not what I meant. There's a difference between C-w and M-b and M-backspace (not sure how those are exactly represented), but
M-dalso behaves the same way, so that it is easy to useM-bto jump in between of somewhere, and then just forward delete a part of something withM-d. For example if you havetry doing
M-b M-b M-b M-d M-backspaceorM-b M-b M-b M-b M-d M-dwhich will yield in
on the other hand, in fish you have to use arrow keys, because you can only navigate like this
and from that point if you try
M-backspace, you'll lose the whole expressionThere are a lot of times when I need to just delete a part of some command and I have to use arrow keys and keep tapping
C-dorbackspaceso delete a word, becauseM-dwould delete the whole command.maxfl commentedon Dec 20, 2012
I agree with @pgan002 about avoiding and complexities like context-dependent behaviour or different behaviour for different keys.
darthdeus commentedon Dec 20, 2012
@pgan002 different behaviour for different keys is the default how all of the other shells behave. That does not mean it is more complicated, because everyone who has been using emacs-like keybindings in shells is used to these.
ridiculousfish commentedon Dec 20, 2012
@darthdeus Thank you for the explanation - I was unaware of the difference between C-w and M-backspace.
I see no reason to expect that C-w and M-backspace, being totally different key combinations, should have the same behavior; in fact doing so would seem like needless duplication. Realizing that other shells have different behavior for C-w and M-backspace makes me drop any objection to different word navigation, so I'll restore the behavior of stopping on punctuation for M-f, M-b, and M-backspace, and we can discuss further from there.
SanskritFritz commentedon Dec 20, 2012
@ridiculousfish Thanks man.
pgan002 commentedon Dec 20, 2012
Having the C-w behavior as a second method of deleting has two advantages that I can think of:
It has several disadvantages:
I think advantage 1 is minor. I expect most users would naturally habituate to using one method because otherwise they would have to think about which method is appropriate every time they want to delete. This is a big reason to strive for orthogonality in general.
Advantage 2 is minor because:
a. Getting used to using the only way to do something is relatively easy, especially if it is the way you are already used to using in GUI text editors
b. Being like other shells is not a high priority for Fish.
Sure, some of the disadvantages are minor too. But on the whole, I feel the arguments are strong against having an additional deletion behavior.
cben commentedon Dec 20, 2012
By same logic, there is no need to have backspace and M-backspace, as the
user will have to think whether to remove a character or a word every time,
let's have only backspace :-)
ridiculousfish commentedon Dec 21, 2012
These two commits should cause meta-f, meta-b, and meta-backspace to stop at more punctuation and more closely match what fish 1.x did.
6b35250
0b1e371
I'm leaving this issue open to permit more discussion.
maxfl commentedon Dec 21, 2012
@ridiculousfish, thank you very much!
Obviously it's now missing 'kill-path-component' in addition to 'backward-kill-path-component'.
There is also an open question: what should be used for partial auto-completion by AltF: word separator or path separator? I myself have not decided yet, so I just raise the question.
SanskritFritz commentedon Dec 21, 2012
I'm happy now :) Thanks @ridiculousfish !
darthdeus commentedon Dec 22, 2012
@ridiculousfish perfect, thank you sooooo much 🍻 It works exactly as I imagined :)
SanskritFritz commentedon Dec 28, 2012
May I close this issue, or should we wait for more comments?