nvim-surround icon indicating copy to clipboard operation
nvim-surround copied to clipboard

How to disable leading and trailing whitespace entirely?

Open alloc33 opened this issue 2 years ago • 2 comments

I can't find a way to disable leading and trailing whitespace? Could you please help me with config?

alloc33 avatar Oct 03 '23 09:10 alloc33

Can you be more specific about the behavior you want?

kylechui avatar Oct 03 '23 14:10 kylechui

I believe it is the same issue as this #122 You can either use ysiw) or change config

["("] = {
            add = { "(", ")" },
            find = function()
                return M.get_selection({ motion = "a(" })
            end,
            delete = "^(. ?)().-( ?.)()$",
        },

skomposzczet avatar Oct 21 '23 09:10 skomposzczet

I'd suggest swapping the default behavior of the left and right surrounds, or providing an option to toggle it.

unnamedname avatar Feb 10 '24 06:02 unnamedname

Changing the default behavior at this point is out of the question, since I find this choice mostly arbitrary, and would rather preserve compatibility with vim-surround. To change this, the configuration provided in this link should suffice.

kylechui avatar Feb 10 '24 06:02 kylechui

Thanks!

While it's nice to keep compatibility for veterans of vim-surround, newcomers are likely to be confused by the extra spaces when modifying surrounds, like cs"' :: "content" -> 'content' but cs([ :: (content) -> [ content ].

What about providing an option? Since I find that left surrounds are clearly more customary than right ones, and that no spaces between surrounds and contents are more common than spaces.

unnamedname avatar Feb 10 '24 07:02 unnamedname

I'm not particularly convinced that an option/toggle would be the preferred way to go about this. I'm currently in the process of trying to open up the internals of this plugin a bit more to make things "more idiomatic" from a Vim perspective; I believe that such a small change like this should just be done by the user.

kylechui avatar Feb 10 '24 22:02 kylechui