Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: COMPLETE_IN_WORD does not work after first expand-or-complete
On Sun, Mar 30, 2025 at 9:40 AM Eric Nielsen <ericbn@xxxxxxx> wrote:
>
> % setopt COMPLETE_IN_WORD
> % zstyle ':completion:*' matcher-list '' 'r:|[._-]=* r:|=*' '+l:|=*'
> % touch foo-bar-baz foo-baz
>
> If I just type "ls z" and <TAB>, I then get to the same "ls foo|-bar" state as before, but pressing <TAB> again moves the cursor past the word immediatially, as if COMPLETE_IN_WORD were not in effect
The menu invoked by a second TAB is based on where the cursor started,
not on where it is. In this case the cursor was originally after the
"z", so if you have "foo-baz" on the line after the first tab, the
second tab selects that as an exact match.
In short, the cursor was not "in" the word (it was instead "past" the
word) for "ls z<TAB>" -- so you don't invoke the complete-in-word
menu.
> If, after typing "ls z" and <TAB>, I press <LEFT><RIGHT> just to "force" the position of the cursor, then further pressing <TAB> does again bring back the expected COMPLETE_IN_WORD behavior.
When you move the cursor, you interrupt the menu series, so the next
tab starts over at the current cursor instead of the previous
position.
The intention when you are in the "ls foo|-bar" state after "z<TAB>"
is for you to recognize that the completion is ambiguous and therefore
either type a disambiguating character (in this example, that would be
"-") or move the cursor to another disambiguation point.
If you start with the cursor to the left of "z", e.g.
% ls z<LEFT><TAB>
Then you get the placement "fo-ba|z" and complete-in-word acts as you expect.
If there's a simple setting to make "touching the end of the word"
behave as if "in" the word, I've forgotten what that is.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author