vim-operator-surround
vim-operator-surround copied to clipboard
Don't consider ignore_space when deleting
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.
_
What is your expected behavior?
If it is
This is an example text.
then you should set g:operator#surround#ignore_space = 1.
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.
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.