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

Improve Ctrl+Left/Right Arrow behavior #3734

Open
almson opened this issue Jan 15, 2017 · 0 comments
Open

Improve Ctrl+Left/Right Arrow behavior #3734

almson opened this issue Jan 15, 2017 · 0 comments

Comments

@almson
Copy link

almson commented Jan 15, 2017

The current behavior of Ctrl+Left Arrow and Ctrl+Right Arrow is a little irregular. For example, in the command ls --al /home/user-1, Ctrl + Left Arrow sets the cursor as follows:

ls --al /home/user-1|
ls --al /home/user-|1
ls --al /home/|user-1
ls --|al /|home/user-1
ls -|-al /home/user-1
|ls --al /home/user-1

Notice the second-to-last line, ls -|-al /home/user. The cursor is at an unexpected position.

However, more than correcting this little bug, I'd like to see Ctrl+Left/Right Arrow stop at both the start and end of words, sequences of punctuation, and sequences of whitespace (ie, three classes of tokens). This slows down the cursor, makes it more predictable, and more useful. Currently, I find Ctrl+Arrow to be too fast and chaotic and I find myself not using it and just waiting for Left/Right Arrow.

Admittedly, there's no "standard behavior" for Ctrl+Left/Right Arrow. Different applications have different behaviors. Some do it like I propose (Mousepad), some like fish (Sublime), some like fish but backwards (Firefox), and others in-between (LibreOffice Write, Netbeans). What I like about the proposed behavior is that:

  1. symmetry - Ctrl + Left Arrow stops at the same locations as Ctrl + Right Arrow
  2. the token classes are a superset of common lexical grammars. Meaning, I can usually get the cursor to the text that I want to delete, insert, or replace.

The proposed rule world result in:

ls --al /home/user-1|
ls --al /home/user-|1
ls --al /home/user|-1
ls --al /home/|user-1
ls --al /home|/user-1
ls --al /|home/user-1
ls --al |/home/user-1
ls --al| /home/user-1
ls --|al /home/user-1
ls |--al /home/user-1
ls| --al /home/user-1
|ls --al /home/user-1

An alternate ruleset that might map even better to common command-line lexical grammars might be to use the following three token classes: whitespace, forward slash, and words+punctuation. The result would be:

ls --al /home/user-1|
ls --al /home/|user-1
ls --al /home|/user-1
ls --al /|home/user-1
ls --al |/home/user-1
ls --al| /home/user-1
ls |--al /home/user-1
ls| --al /home/user-1
|ls --al /home/user-1
@zanchey zanchey added this to the fish-future milestone Feb 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants