martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.25k stars 258 forks source link

Ampersand & requires escape when using change (c) #1042

Closed ddkn closed 1 year ago

ddkn commented 1 year ago

Hello everyone,

Has anyone had any issues with using the :c// command to add & characters into the selections? I know when using :x// you need to escape regular expression special characters but when using :c// you do not need to escape them, however for ampersands & they require being escaped.

I was working on a latex file (specifically tables) and discovered this issue, lets say I have the following string

a b c d

I select all spaces by C-v to select the line, then :x/ /c/&/ nothing happens, but with :x/ /c/\&/ it inserts as expected. I think escaping here seems like an inconsistency, unless this is a part of sam, or caveat with lua, or am I missed something.

The issues works for larger trappings too such as a b c, :x/[ ]+/c/ \& / if I want to insert ampersands with spaces around them.

For context I am running on v0.7 on Debian.

Cheers,

ninewise commented 1 year ago

This is expected: an unescaped & is replaced by the match, in this case a space. So x/ /c/&/ would replace spaces by spaces.