HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
tpope
vim-surround
Vim Script2010–2025
tpope / vim-surround

vim-surround

surround.vim: Delete/change/add parentheses/quotes/XML-tags/much more with ease

27Distinct people
28Mentions
0Explicit recommenders
14.1KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

surround.vim: Delete/change/add parentheses/quotes/XML-tags/much more with ease

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 8–Nov 15 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/15/2026, 2:04:58 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year28 dated mentions

Observed mentions: 2010-07-04 04:51:17 UTC to 2025-07-04 18:14:48 UTC.

012342010-01-01 00:00:00 UTC to 2011-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20102011-01-01 00:00:00 UTC to 2012-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments2012-01-01 00:00:00 UTC to 2013-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2013-01-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2014-01-01 00:00:00 UTC to 2015-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments20172018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20102010-01-01 00:00:00 UTC2011-01-01 00:00:00 UTC101
20112011-01-01 00:00:00 UTC2012-01-01 00:00:00 UTC404
20122012-01-01 00:00:00 UTC2013-01-01 00:00:00 UTC303
20132013-01-01 00:00:00 UTC2014-01-01 00:00:00 UTC000
20142014-01-01 00:00:00 UTC2015-01-01 00:00:00 UTC000
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC101
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC202
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC202
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC202
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC202
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC101
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC404
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC312
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC101
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC101

From the project README

An excerpt from the repository, fetched Nov 12, 2026.

Read the project’s introduction
surround.vim Surround.vim is all about "surroundings": parentheses, brackets, quotes, XML tags, and more. The plugin provides mappings to easily delete, change and add such surroundings in pairs. It's easiest to explain with examples. Press cs"' inside "Hello world!" to change it to 'Hello world!' Now press cs'<q> to change it to <q>Hello world!</q> To go full circle, press cst" to get "Hello world!" To remove the delimiters entirely, press ds". Hello world! Now with the cursor on "Hello", press ysiw] (iw is a text object). [Hello] world! Let's make that braces and add some space (use } instead of { for no space): cs]{ { Hello } world! Now wrap the entire line in parentheses with yssb or yss). ({ Hello } world!) Revert to the original text: ds{ds) Hello world! Emphasize hello: ysiw<em> <em>Hello</em> world! Finally, let's try out visual mode. Press a capital V (for linewise visual mode) followed by S<p class="important">. <p class="important"> <em>Hello</em> world! </p> This plugin is very powerful for HTML and XML editing, a niche which currently seems underfilled in Vim land. (As opposed to HTML/XML inserting, for which many plugins are available). Adding, changing, and removing pairs of tags simultaneously is a breeze. The . command will work with ds, cs, and yss if you install repeat.vim. Installation Install using your favorite package manager, or use Vim's built-in package support: mkdir -p ~/.vim/pack/tpope/start cd ~/.vim/pack/tpope/start git clone https://tpope.io/vim/surround.git vim -u NONE -c "helptags surround/doc" -c q FAQ How do I surround without adding a space? Only the opening brackets—[, {, and (—add a space. Use a closing bracket, or the b (() and B ({) aliases. Contributing See the contribution guidelines for pathogen.vim. Self-Promotion Like surround.vim? Star the repository on GitHub and vote for it on vim.org. Love surround.vim? Follow tpope on GitHub and Twitter. License Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. See :help license.
Read the full README on GitHub

What Hacker News says

28 sources
I don't know what exactly you mean by pasting a function around the selection, but you can paste selections, registers or even files at specific lines with some vim-fu. If it's generic enough you could write a function or even a keyboard shortcut if it's very simple. I have set ",',(,[,{ in visual mode to cut the selection insert the pairs then paste it back as a very hacky solution, but it gets the job done. If you want something more advanced to add or change anything around the selection tpope has solved that with vim-surround[1]. [1]: https://github.com/tpope/vim-surround
In Difftastic, a structural diff tool that understands syntax
Surround is a plugin which adds more text objects: https://github.com/tpope/vim-surround cs"': change surrounding quotes, e.g. "foo" -> 'foo' cs([: change surrounding brackets, e.g. (foo) -> [ foo ] ( cs]) would omit the spaces) ci": change in quotes, e.g. "foo" -> "" (in insert mode between the quotes) ca": change around quotes, e.g. x"foo"y -> xy (in insert mode between x and y viWS<tag>: add tag around current word using visual mode, e.g. foo -> <tag>foo</tag> dst: delete surrounding tag, e.g. <tag>foo</tag> -> foo It's really good. I'm not familiar with argument.
In Ask HN: Is Vim still worth learning?
I hopped on the Vim train about 2-3 years ago and haven't looked back. That said, I do use VSCode with Vim key bindings more than anything. It doesn't have everything Vim does, but it does have Tim Pope's almighty surround plugin, out-of-the-box. https://github.com/tpope/vim-surround ys2w) will put brackets around the next 2 words. That is a beautiful thing.
In I Still Use Vim
Below are some various things I actually use... and not all of the junk in my vimrc I don't actually use. Plugins: https://github.com/tmhedberg/matchit https://github.com/tpope/vim-sleuth https://github.com/tpope/vim-repeat https://github.com/tpope/vim-surround https://github.com/junegunn/fzf.vim (also see https://jesseleite.com/posts/2/its-dangerous-to-vim-alone-ta... ) Some snippets: https://github.com/mhinz/vim-galore#change-cursor-style-depe... https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-... and a similar snippet: " consistent direction regardless of initial charsearch direction for ; and , nnoremap <expr> ; ',;'[getcharsearch().forward] nnoremap <expr> , ';,'[getcharsearch().forward] I use my arrow keys for buffer navigation in normal mode: nnoremap <up> :Buffers<cr> nnoremap <down> :b#<cr> nn
Read the rest
oremap <left> :bp<cr> nnoremap <right> :bn<cr> ...and disable them in insert mode: inoremap <down> <nop> inoremap <left> <nop> inoremap <right> <nop> inoremap <up> <nop>
In Ask HN: Share your .vimrc file and what plug-ins you use
People seem to swear by NerdTree, but I personally don't see the purpose of it. Sure it may be nice to see your file structure sometimes, but having a terminal open or even just the actual folder window open solves that. Everything else can be done with the built-in :Ex command, which lets you navigate to open files, create new files, rename, delete, mostly everything you want. As for other plug-ins, there are a few I would recommend (can you tell I'm a Tim Pope fan?): - vim-commentary: Gives bindings for commenting out code quickly: https://github.com/tpope/vim-commentary - vim-surround: Easily surround selected text with symbols: https://github.com/tpope/vim-surround - vim-unimpared: Adds bindings for some misc. commands, like enabling relative line numbers and spellcheck: https://github.com/tpope/vim-unimpaired - vim-repeat: Allows man
Read the rest
y more commands to be repeated with . : https://github.com/tpope/vim-repeat - VimCompletesMe: A much more bare-bones auto-completion tool than YouCompleteMe, hitting tab gives you matches from your previously typed text. It's also all in vimscript so it's much easier to install and manage: https://github.com/ajh17/VimCompletesMe - Pathogen: A plug-in manager, if you can call it that. It simply re-adjusts the file paths so you can centralize your plugin directory. Some plug-in managers will auto-update, but I never liked that, just run git pull if you wish to update a plugin: https://github.com/tpope/vim-pathogen There are some other cosmetic ones I like as well, like airline, and vim-highlightyank, but that's a personal preference.
In Vim plugins I use

Showing the 15 most recent of 28 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.