What does HackerNews think of vim-surround?

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

Language: Vim Script

Vim can do this with the following plugin: https://github.com/tpope/vim-surround

I exclusively use the visual mode commands though, because I find the normal-mode commands confusing.

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: add tag around current word using visual mode, e.g. foo -> foo

dst: delete surrounding tag, e.g. foo -> foo

It's really good. I'm not familiar with argument.

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.

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  ; ',;'[getcharsearch().forward]
    nnoremap  , ';,'[getcharsearch().forward]
I use my arrow keys for buffer navigation in normal mode:

    nnoremap  :Buffers
    nnoremap  :b#
    nnoremap  :bp
    nnoremap  :bn
...and disable them in insert mode:

    inoremap  
    inoremap  
    inoremap  
    inoremap  
Vim-surround is a nice solution for this. It’s developed by the same developer who wrote vim-fugitive. It is also available non the vim plugin for VSCode by turning on a setting.

https://github.com/tpope/vim-surround

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 many 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.

Also, vim-surround is one of those things that, once you've used it for a while, it's impossible to think of editing text without it: https://github.com/tpope/vim-surround