Skip to content

Various problems with word recognition #384

Closed

Description

@SanskritFritz

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

Activity

  1. melissaboiko commented on Nov 14, 2012

    @melissaboiko
    Contributor

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

  2. SanskritFritz commented on Nov 14, 2012

    @SanskritFritz
    ContributorAuthor

    I just want the old behaviour back.

  3. stestagg commented on Nov 14, 2012

    @stestagg
    Contributor

    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]:

    I just want the old behaviour back.

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/384#issuecomment-10366732.

  4. melissaboiko commented on Nov 14, 2012

    @melissaboiko
    Contributor

    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.

  5. maxfl commented on Nov 15, 2012

    @maxfl
    Contributor

    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.

  6. SanskritFritz commented on Nov 15, 2012

    @SanskritFritz
    ContributorAuthor

    Honestly I think we should find out what commit caused the change and revert that part.

  7. maxfl commented on Nov 16, 2012

    @maxfl
    Contributor

    It seems that behaviour's changed after commit: 8eb53ea

    commit 8eb53ea
    Author: ridiculousfish [email protected]
    Date: Thu Oct 4 14:35:03 2012 -0700

    Rewrite kill behavior (aka control-W) to do something better
    Fixes https://github.com/fish-shell/fish-shell/issues/327
    
  8. ridiculousfish commented on Nov 19, 2012

    @ridiculousfish
    Member

    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

  9. maxfl commented on Nov 19, 2012

    @maxfl
    Contributor

    It also should be comfortable to:

    1. Work with option arguments: change --option=arg1 to --option=arg2, i.e. it word is divided by '='
    2. Sometimes it also useful on changing long options:
      --long-option1 -> --long-option2
      which is possible when words are separated by '-'.
    3. Changing the file extension (very often issue). One could think of file extension as path component. i.e. stop on '.'.
    4. Work with comma-separated list. Stop on ','. {foo,bar,bar} is now a single word.
    5. 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.
    6. Quotes: "$foo"bar is considered to be a single word now. To change bar comfortably one should introduce '"' as word separator.
    7. Brackets/parentheses: these are all words now $var[1], text(echo), text{text}.
    8. Dollar sign: $PATH$PATH is also a single word.
    9. '@' and ':' are also used in paths: [email protected]:some/path.
    10. Wildcards to flexibly change patterns: foo*bar?
    11. Tilde, plus sign, percent sign, backslash.

    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.

  10. melissaboiko commented on Nov 19, 2012

    @melissaboiko
    Contributor

    @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:

    "$foo"bar
    '$foo'bar
    foo bar
    foo/bar
    foo=bar
    foo-bar
    foo.bar
    foo>bar
    foo^bar
    foo,bar
    foo_bar
    
  11. maxfl commented on Nov 19, 2012

    @maxfl
    Contributor

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

  12. SanskritFritz commented on Nov 20, 2012

    @SanskritFritz
    ContributorAuthor

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

  13. maxfl commented on Nov 25, 2012

    @maxfl
    Contributor

    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.

  14. darthdeus commented on Dec 14, 2012

    @darthdeus

    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.

  15. SanskritFritz commented on Dec 14, 2012

    @SanskritFritz
    ContributorAuthor

    I fully agree with @darthdeus here. Please, pretty please make fish stop again at periods and dashes and stuff.

  16. 13 remaining items

  17. darthdeus commented on Dec 20, 2012

    @darthdeus

    @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

    echo hello_world.txt<M-backspace>
    echo hello_world.<M-backspace>
    echo hello_
    

    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

    ssh [email protected]:/var/apps
    

    try doing M-b M-b M-b M-d M-backspace or M-b M-b M-b M-b M-d M-d

    which will yield in

    ssh foo@<cursor here>:/var/apps
    

    on the other hand, in fish you have to use arrow keys, because you can only navigate like this

    ssh [email protected]:/<cursor here>var/apps
    

    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.

  18. maxfl commented on Dec 20, 2012

    @maxfl
    Contributor

    I agree with @pgan002 about avoiding and complexities like context-dependent behaviour or different behaviour for different keys.

  19. darthdeus commented on Dec 20, 2012

    @darthdeus

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

  20. ridiculousfish commented on Dec 20, 2012

    @ridiculousfish
    Member

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

  21. SanskritFritz commented on Dec 20, 2012

    @SanskritFritz
    ContributorAuthor

    @ridiculousfish Thanks man.

  22. pgan002 commented on Dec 20, 2012

    @pgan002

    Having the C-w behavior as a second method of deleting has two advantages that I can think of:

    1. It is more flexible
    2. Users of other shells won't miss it

    It has several disadvantages:

    1. It is not orthogonal
    2. One of the methods is not very discoverable once you know the other (as illustrated by ridiculousfish)
    3. If you do discover it, it can be confusing. Also (as far as I can see) there is no corresponding method of navigating.
    4. It is more complicated to explain
    5. 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.

  23. cben commented on Dec 20, 2012

    @cben
    Contributor

    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 :-)

  24. ridiculousfish commented on Dec 21, 2012

    @ridiculousfish
    Member

    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.

  25. maxfl commented on Dec 21, 2012

    @maxfl
    Contributor

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

  26. SanskritFritz commented on Dec 21, 2012

    @SanskritFritz
    ContributorAuthor

    I'm happy now :) Thanks @ridiculousfish !

  27. darthdeus commented on Dec 22, 2012

    @darthdeus

    @ridiculousfish perfect, thank you sooooo much 🍻 It works exactly as I imagined :)

  28. SanskritFritz commented on Dec 28, 2012

    @SanskritFritz
    ContributorAuthor

    May I close this issue, or should we wait for more comments?

  29. removed this from the fish-future milestone on Feb 5, 2016
  30. locked as resolved and limited conversation to collaborators on Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions