[vim/vim] add optional surround package (PR #20596)

28 views
Skip to first unread message

Maxim Kim

unread,
Jun 21, 2026, 2:07:58 AM (3 days ago) Jun 21
to vim/vim, Subscribed

There are 2 very well known and established plugins to surround text in vim:

However it might be good to have one in the vim itself.

This package can do most if not all of what surround.vim can and by default uses the same ys, ds and cs operators, S for visual mode. It is less fancy than vim-sandwich which provides quite a few additional nice things.

Key difference is implementation, I use 3 simple operators (add, remove and change surround) that are naturally dot repeatable without using . remapping or repeat.vim.

Additionally, adding surround is different: ys(iw vs ysiw( (surround.vim) vs saiw( (vim-sandwich), basically the move comes the last.

asciicast

I will add tests in either case (whether this would or wouldn't be accepted).


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/20596

Commit Summary

File Changes

(5 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20596@github.com>

bfrg

unread,
Jun 21, 2026, 8:28:17 AM (3 days ago) Jun 21
to vim/vim, Subscribed
bfrg left a comment (vim/vim#20596)

And why did you change the order in the mapping? Considering most users are already used to vim-surround (or vim-sandwich) style mappings, I don't think it's wise to change it.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20596/c4761960225@github.com>

Maxim Kim

unread,
Jun 21, 2026, 8:51:42 AM (3 days ago) Jun 21
to vim/vim, Subscribed
habamax left a comment (vim/vim#20596)

And why did you change the order in the mapping? Considering most users are already used to vim-surround (or vim-sandwich) style mappings, I don't think it's wise to change it.

Initially I wanted to have the same order as surround.vim, however, the implementation is then:

  1. either not dot repeatable (it would always ask for the char when you try to repeat with .)
  2. or would require additional . mapping.

Which I wanted to avoid. So it is ys{char}{motion} not ys{motion}{char}.

PS, it should be easy with . mapping though. If general consensus would be to have the same ys{motion}{char} I can change it.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20596/c4762029967@github.com>

Maxim Kim

unread,
Jun 21, 2026, 9:03:12 AM (3 days ago) Jun 21
to vim/vim, Subscribed
habamax left a comment (vim/vim#20596)

Let me try one additional idea, maybe it would work.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20596/c4762059251@github.com>

Maxim Kim

unread,
Jun 21, 2026, 9:38:36 AM (3 days ago) Jun 21
to vim/vim, Subscribed
habamax left a comment (vim/vim#20596)

And why did you change the order in the mapping? Considering most users are already used to vim-surround (or vim-sandwich) style mappings, I don't think it's wise to change it.

I knew, I was missing something really simple to actually make it ys{motion}{char}. Thanks @bfrg for spelling "I don't think it's wise to change it." It refreshed my thought process :).

A simple boolean var solved the issue I was trying to tackle for many other hours.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20596/c4762154078@github.com>

BenYip

unread,
Jun 22, 2026, 2:07:58 PM (yesterday) Jun 22
to vim/vim, Subscribed
bennyyip left a comment (vim/vim#20596)

can we have ys<motion>f? i use it a lot.

https://github.com/tpope/vim-surround/blob/master/doc/surround.txt#L138


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20596/c4771344969@github.com>

Christian Brabandt

unread,
Jun 22, 2026, 2:51:27 PM (yesterday) Jun 22
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#20596)

Hm, thanks but this is quite a bit of code you are adding here. What do others think?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20596/c4771789945@github.com>

Maxim Kim

unread,
Jun 22, 2026, 7:29:41 PM (yesterday) Jun 22
to vim/vim, Subscribed
habamax left a comment (vim/vim#20596)

we can, although it would be a bit more code :)


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20596/c4774076187@github.com>

Maxim Kim

unread,
Jun 22, 2026, 11:51:30 PM (23 hours ago) Jun 22
to vim/vim, Subscribed
habamax left a comment (vim/vim#20596)

@chrisbra, it is indeed more code than some of the other optional packages, but it is less than helptoc, matchit or editorconfig. Not to mention netrw :)


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20596/c4775430152@github.com>

Maxim Kim

unread,
9:50 PM (1 hour ago) 9:50 PM
to vim/vim, Subscribed
habamax left a comment (vim/vim#20596)

This is done.

@bennyyip I will add function surround add/remove/change later.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/20596/c4785177864@github.com>

Reply all
Reply to author
Forward
0 new messages