zsh-workers
 help / color / mirror / code / Atom feed
* Bug: zsh vim textobjects and slash
@ 2018-05-18  9:08 Itay Shakury
  2018-05-18 12:26 ` Oliver Kiddle
  0 siblings, 1 reply; 8+ messages in thread
From: Itay Shakury @ 2018-05-18  9:08 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 977 bytes --]

[I am not subscribed to this list, so please little r me when replying.
also, hope this is the appropriate place to report a bug in zsh, please let
me know if it isn't].

zsh vim mode supports vim textobjects but the behavior is different then
vim. one particularly annoying case is the 'word' text object which in zsh
separates on whitespace but in vim on other special characters such as
slash '/'.

Example: if I'm typing `ls /var/lib/docker` and want to change 'lib' to
'run', I would place the cursor in the 'lib' word, and do `ciw`. In vim
this would delete the 'lib' word and put me in insert mode. In zsh it
deletes the entire path ('var/lib/docker').

I'm constantly hitting this issue which actually made me adapt the habit of
not using `ciw` anymore in zsh *and in vim*. So zsh's vim support actually
ruined my vim skills instead of supporting it... :(

I have found this similar other report:
http://www.zsh.org/cgi-bin/mla/wilma_hiliter/workers/2017/msg00852.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug: zsh vim textobjects and slash
  2018-05-18  9:08 Bug: zsh vim textobjects and slash Itay Shakury
@ 2018-05-18 12:26 ` Oliver Kiddle
  2018-05-18 17:51   ` Itay Shakury
  2018-05-18 18:15   ` Daniel Shahaf
  0 siblings, 2 replies; 8+ messages in thread
From: Oliver Kiddle @ 2018-05-18 12:26 UTC (permalink / raw)
  To: Itay Shakury; +Cc: zsh-workers

Itay Shakury wrote:
> Example: if I'm typing `ls /var/lib/docker` and want to change 'lib' to
> 'run', I would place the cursor in the 'lib' word, and do `ciw`. In vim
> this would delete the 'lib' word and put me in insert mode. In zsh it
> deletes the entire path ('var/lib/docker').

This bug doesn't occur with a default zsh setup. I do, however, have
a theory as to the cause. I suspect that you are using a plugin that
redefines every zle widget (every key in effect).
zsh-syntax-highlighting perhaps?

If you do "bindkey -M viopp iw", you should see:
  "iw" select-in-word
And if you do "zle -lL select-in-word", you should get nothing. If you
do get something, it is likely that select-in-word has been redefined.

The trouble is that internally, one function handles all of iw, iW, aw
and aW. It is checking whether the invoked widget is select-in-word. But
if you've redefined that, the check returns false and you get iW
(select-in-blank-word) behaviour.

I think this has been fixed in a6135f6 (41191) which is in zsh 5.4.

I'm not quite sure of how to remove the custom select-in-word widget
other than by disabling the entire plugin. zle -D select-in-word seems
to cause other problems. If I run that after sourcing
zsh-syntax-highlighting, I can get a seg fault, including with 5.5.

Oliver


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug: zsh vim textobjects and slash
  2018-05-18 12:26 ` Oliver Kiddle
@ 2018-05-18 17:51   ` Itay Shakury
  2018-05-19 12:19     ` Itay Shakury
  2018-05-18 18:15   ` Daniel Shahaf
  1 sibling, 1 reply; 8+ messages in thread
From: Itay Shakury @ 2018-05-18 17:51 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1543 bytes --]

> I think this has been fixed in a6135f6 (41191) which is in zsh 5.4.

THANKS! Confirmed working in 5.5.1

On Fri, May 18, 2018 at 3:26 PM Oliver Kiddle <okiddle@yahoo.co.uk> wrote:

> Itay Shakury wrote:
> > Example: if I'm typing `ls /var/lib/docker` and want to change 'lib' to
> > 'run', I would place the cursor in the 'lib' word, and do `ciw`. In vim
> > this would delete the 'lib' word and put me in insert mode. In zsh it
> > deletes the entire path ('var/lib/docker').
>
> This bug doesn't occur with a default zsh setup. I do, however, have
> a theory as to the cause. I suspect that you are using a plugin that
> redefines every zle widget (every key in effect).
> zsh-syntax-highlighting perhaps?
>
> If you do "bindkey -M viopp iw", you should see:
>   "iw" select-in-word
> And if you do "zle -lL select-in-word", you should get nothing. If you
> do get something, it is likely that select-in-word has been redefined.
>
> The trouble is that internally, one function handles all of iw, iW, aw
> and aW. It is checking whether the invoked widget is select-in-word. But
> if you've redefined that, the check returns false and you get iW
> (select-in-blank-word) behaviour.
>
> I think this has been fixed in a6135f6 (41191) which is in zsh 5.4.
>
> I'm not quite sure of how to remove the custom select-in-word widget
> other than by disabling the entire plugin. zle -D select-in-word seems
> to cause other problems. If I run that after sourcing
> zsh-syntax-highlighting, I can get a seg fault, including with 5.5.
>
> Oliver
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug: zsh vim textobjects and slash
  2018-05-18 12:26 ` Oliver Kiddle
  2018-05-18 17:51   ` Itay Shakury
@ 2018-05-18 18:15   ` Daniel Shahaf
  1 sibling, 0 replies; 8+ messages in thread
From: Daniel Shahaf @ 2018-05-18 18:15 UTC (permalink / raw)
  To: zsh-workers; +Cc: Itay Shakury

Oliver Kiddle wrote on Fri, 18 May 2018 14:26 +0200:
> I'm not quite sure of how to remove the custom select-in-word widget
> other than by disabling the entire plugin.

z-sy-h has a branch that switches it to use zle-line-pre-redraw in lieu
of wrapping all widgets.  The branch is called feature/redrawhook.

(It really should be merged into z-sy-h master at some point, but
nowadays I'm taking somewhat of a back seat in the z-sy-h maintainers'
car due to lack of time.)

> zle -D select-in-word seems
> to cause other problems. If I run that after sourcing
> zsh-syntax-highlighting, I can get a seg fault, including with 5.5.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug: zsh vim textobjects and slash
  2018-05-18 17:51   ` Itay Shakury
@ 2018-05-19 12:19     ` Itay Shakury
  2018-05-19 13:56       ` Daniel Shahaf
  0 siblings, 1 reply; 8+ messages in thread
From: Itay Shakury @ 2018-05-19 12:19 UTC (permalink / raw)
  To: Oliver Kiddle, zsh-workers

[-- Attachment #1: Type: text/plain, Size: 2502 bytes --]

If I may raise another issue with VIM mode: In insert mode, delete using
backspace has a strange behavior.
Example:
I type 'kubectl get pods', and want to delete the word 'get'. in normal
mode I move the cursor to right after the word 'get', then 'i' for insert
mode and and press backspace - doesn't work. while still in insert mode, I
move the cursor using the arrows forward (into the word 'pods') - backspace
works up until the point where I entered insert mode (so still can't delete
'get').
One would guess that the bug is that insert only makes the text after the
cursor editable, but no: while still in insert mode, move the cursor to
anywhere before the place where entered insert mode (somewhere in 'kubectl
get') and make any addition, like add a single char - now backspace works
everywhere and I can delete even the word 'get').

On Fri, May 18, 2018 at 8:51 PM Itay Shakury <itaysk@codefresh.io> wrote:

> > I think this has been fixed in a6135f6 (41191) which is in zsh 5.4.
>
> THANKS! Confirmed working in 5.5.1
>
> On Fri, May 18, 2018 at 3:26 PM Oliver Kiddle <okiddle@yahoo.co.uk> wrote:
>
>> Itay Shakury wrote:
>> > Example: if I'm typing `ls /var/lib/docker` and want to change 'lib' to
>> > 'run', I would place the cursor in the 'lib' word, and do `ciw`. In vim
>> > this would delete the 'lib' word and put me in insert mode. In zsh it
>> > deletes the entire path ('var/lib/docker').
>>
>> This bug doesn't occur with a default zsh setup. I do, however, have
>> a theory as to the cause. I suspect that you are using a plugin that
>> redefines every zle widget (every key in effect).
>> zsh-syntax-highlighting perhaps?
>>
>> If you do "bindkey -M viopp iw", you should see:
>>   "iw" select-in-word
>> And if you do "zle -lL select-in-word", you should get nothing. If you
>> do get something, it is likely that select-in-word has been redefined.
>>
>> The trouble is that internally, one function handles all of iw, iW, aw
>> and aW. It is checking whether the invoked widget is select-in-word. But
>> if you've redefined that, the check returns false and you get iW
>> (select-in-blank-word) behaviour.
>>
>> I think this has been fixed in a6135f6 (41191) which is in zsh 5.4.
>>
>> I'm not quite sure of how to remove the custom select-in-word widget
>> other than by disabling the entire plugin. zle -D select-in-word seems
>> to cause other problems. If I run that after sourcing
>> zsh-syntax-highlighting, I can get a seg fault, including with 5.5.
>>
>> Oliver
>>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug: zsh vim textobjects and slash
  2018-05-19 12:19     ` Itay Shakury
@ 2018-05-19 13:56       ` Daniel Shahaf
  2018-05-23 14:00         ` Itay Shakury
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Shahaf @ 2018-05-19 13:56 UTC (permalink / raw)
  To: Itay Shakury, Oliver Kiddle, zsh-workers

Itay Shakury wrote on Sat, 19 May 2018 15:19 +0300:
> I type 'kubectl get pods', and want to delete the word 'get'. in normal
> mode I move the cursor to right after the word 'get', then 'i' for insert
> mode and and press backspace - doesn't work.

That's vi compatible behaviour.  (Vim does it too in its Vi-compatible
mode, see :help 'backspace' there.)  You can avoid it by binding your
backspace key to backward-delete-char rather than vi-delete-char:

eval "$(bindkey -M viins -L | sed -n -e 's/vi-backward-delete-char/backward-delete-char/p')"

Cheers,

Daniel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug: zsh vim textobjects and slash
  2018-05-19 13:56       ` Daniel Shahaf
@ 2018-05-23 14:00         ` Itay Shakury
  2018-05-23 15:25           ` Bart Schaefer
  0 siblings, 1 reply; 8+ messages in thread
From: Itay Shakury @ 2018-05-23 14:00 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Oliver Kiddle, zsh-workers

[-- Attachment #1: Type: text/plain, Size: 875 bytes --]

Daniel - Thanks!
These little tips are life changing for me :) wish there was some doc with
all those vim related "fixes" for the common user.
Again - thanks for the quick and helpful response.
Itay

On Sat, May 19, 2018 at 4:57 PM Daniel Shahaf <d.s@daniel.shahaf.name>
wrote:

> Itay Shakury wrote on Sat, 19 May 2018 15:19 +0300:
> > I type 'kubectl get pods', and want to delete the word 'get'. in normal
> > mode I move the cursor to right after the word 'get', then 'i' for insert
> > mode and and press backspace - doesn't work.
>
> That's vi compatible behaviour.  (Vim does it too in its Vi-compatible
> mode, see :help 'backspace' there.)  You can avoid it by binding your
> backspace key to backward-delete-char rather than vi-delete-char:
>
> eval "$(bindkey -M viins -L | sed -n -e
> 's/vi-backward-delete-char/backward-delete-char/p')"
>
> Cheers,
>
> Daniel
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Bug: zsh vim textobjects and slash
  2018-05-23 14:00         ` Itay Shakury
@ 2018-05-23 15:25           ` Bart Schaefer
  0 siblings, 0 replies; 8+ messages in thread
From: Bart Schaefer @ 2018-05-23 15:25 UTC (permalink / raw)
  To: Itay Shakury; +Cc: zsh-workers

Generally speaking, zsh's vi mode is going to act like vim's vi
emulation mode, not like vim native mode, because zsh's vi mode was
based on the original 4.x BSD vi circa 1990 and any vim-like features
came later.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-05-23 15:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-18  9:08 Bug: zsh vim textobjects and slash Itay Shakury
2018-05-18 12:26 ` Oliver Kiddle
2018-05-18 17:51   ` Itay Shakury
2018-05-19 12:19     ` Itay Shakury
2018-05-19 13:56       ` Daniel Shahaf
2018-05-23 14:00         ` Itay Shakury
2018-05-23 15:25           ` Bart Schaefer
2018-05-18 18:15   ` Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).