kylechui / nvim-surround

Add/change/delete surrounding delimiter pairs with ease. Written with :heart: in Lua.
MIT License
2.92k stars 60 forks source link

How to disable leading and trailing whitespace entirely? #264

Closed xbladesub closed 5 months ago

xbladesub commented 9 months ago

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

kylechui commented 9 months ago

Can you be more specific about the behavior you want?

skomposzczet commented 8 months ago

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 = "^(. ?)().-( ?.)()$",
        },
unnamedname commented 5 months ago

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

kylechui commented 5 months ago

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.

unnamedname commented 5 months ago

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.

kylechui commented 5 months ago

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.