kylechui / nvim-surround

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

What is the difference between this and `vim-surround` or `vim-sandwich`? #140

Closed ok-nick closed 2 years ago

ok-nick commented 2 years ago

Hi, I am interested in switching to this plugin, but what advantages and disadvantages does it have over its predecessors? Obviously, for one, it's written in Lua, making it a much better configuration experience. What else?

Perhaps a table should be included in the README comparing them all to give potential users more of an inclination to migrate.

kylechui commented 2 years ago

Hi there! There is this wiki page that I was originally planning on using for migration, but it is kind of out-of-date. I've mostly been focusing on patching bugs and trying to push out new features as soon as possible before I get busy with schoolwork again. I personally haven't really used vim-sandwich much, but from the little experience I do have, nvim-surround covers most of the common functionality, e.g. add/modify surrounds, but does not yet include the "sandwich" surrounds (see #135). This project mostly aims to be more or less a superset of everything vim-surround does, with a few minor tweaks that I find to be "more sensible". Most notably, < adds a <, > pair to the buffer instead of adding an HTML-style tag (which is done via t or T). As for bonus features, here we go:

In general I've tried to open this plugin up to be as extensible as possible, instead of hard-coding specific cases. For example, the HTML tags and function calls are actually not a part of the core plugin itself, but rather just part of the default user configuration that I've provided. You can see #53 to see some things that myself and others have created, to help with workflows.

TL;DR Pattern-based surrounds allow for modifying function calls, e.g. dsf, dot-repeat works out-of-the-box, and the extensibility of the plugin using Lua is unmatched by its VimL counterparts.

kylechui commented 2 years ago

But yeah I definitely agree that I'm not really incentivizing people to switch at the moment; so far it's mostly just been people trying it out and liking the stuff that I've put in :) Hopefully in the future once I've "settled down" on adding new features/bug fixes, I can write some better docs on why this is a good alternative to older surround plugins.

kylechui commented 2 years ago

BTW @ok-nick if you're looking at other surround plugins, mini.surround is also a notable alternative that I would recommend.