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

Don't consider ignore_space when deleting #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hiroebe
Copy link

@hiroebe hiroebe commented Oct 14, 2020

According to the doc, g:operator#surround#ignore_space affects <Plug>(operator-surround-append) and <Plug>(operator-surround-replace), not <Plug>(operator-surround-delete).

Currently, sda' doesn't work with the example below when g:operator#surround#ignore_space = 0 .
(Assume that map sd <Plug>(operator-surround-delete) and _ is the cursor position.)

This is an 'example' text.
             _

@rhysd
Copy link
Owner

rhysd commented Oct 16, 2020

What is your expected behavior?

If it is

This is an example text.

then you should set g:operator#surround#ignore_space = 1.

@rhysd
Copy link
Owner

rhysd commented Oct 16, 2020

Let me explain the detail of the behavior.

This is an 'example' text.

In this text, va' selects 'example' , not 'example' (please notice last white space). vim-operator-surround tries to find out the surrounding from the text 'example' . When g:operator#surround#ignore_space = 1, the last white space is ignored. So vim-operator-surround finds the first ' and the last ' are pair of delimiters. However, if the variable is set to 0, the last space is not ignored. In this case vim-operator-surround compares the first ' and the last and they are not a pair of delimiters so the 'block not found' error occurs.

@hiroebe
Copy link
Author

hiroebe commented Oct 16, 2020

Thank you for your explanation, and I understand the behavior.

Now let me explain the behavior I want.
When appending or replacing, g:operator#surround#ignore_space = 0 is useful because I want the selection of example to become 'example ' (not 'example' ).
However, I'm wondering that there are no advantages to applying g:operator#surround#ignore_space = 0 when deleting. (It enables nothing, and only prevent me from deleting what I want, IMO.)
This is why my suggestion is to make g:operator#surround#ignore_space = 0 have no effect to <Plug>(operator-surround-delete).

Of course you can decline it, but then the doc might have to be updated, because it says:

g:operator#surround#ignore_space              *g:operator#surround#ignore_space*

    If the value is non-zero, surroundings ignores white spaces when they are
    added with <Plug>(operator-surround-append) or
    <Plug>(operator-surround-replace).    <--- Also affects <Plug>(operator-surround-delete)!
    The default value is 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants