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

Make the :global command respect the \zs regex atom. #13667

Open
atimholt opened this issue Jan 2, 2021 · 0 comments
Open

Make the :global command respect the \zs regex atom. #13667

atimholt opened this issue Jan 2, 2021 · 0 comments
Labels
enhancement feature request

Comments

@atimholt
Copy link

atimholt commented Jan 2, 2021

(n/a issue template “fields” removed)

Actual behaviour

When the pattern given to a :global command is given a “starting position” (the zero-width \zs atom) at some point after a new-line atom (\n), the position of the action taken is not that of the beginning of the match (at the \zs), but instead at the beginning of the pattern.

e.g. (toy example):

first line
second line
:g`first line\n\zssecond line`normal A!!!<1b>
first line!!!
second line

Expected behaviour

The global command should account for the actual starting position of the match, which is not always the same thing as whatever buffer position matches the beginning of the pattern. The entire purpose of the \zs atom is to allow for arbitrarily narrow qualification of a match using the context in which the match appears, but which is not actually part of it. Everything before a \zs is, conceptually, a wholly separate entity, which by its nature is immediately adjacent, but which may be completely unrelated otherwise.

Back to the “actual behavior” example, the given command should have this result:

first line
second line!!!

Possible behavior extension:

Allow for a kind of global command that understands the character-wise position of the match.

e.g. (toy example):

one banana
two apples
:g`\v^\k+\s+\zs\a`normal vgU
one Banana
two Apples
@atimholt atimholt added the enhancement feature request label Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature request
Projects
None yet
Development

No branches or pull requests

1 participant