tpope / vim-surround

surround.vim: Delete/change/add parentheses/quotes/XML-tags/much more with ease
https://www.vim.org/scripts/script.php?script_id=1697
13.39k stars 444 forks source link

Add full support for | ... | pipe brackets #367

Closed myarcana closed 1 year ago

myarcana commented 1 year ago

Some popular languages, e.g. ruby and rust, use |one, two, three|-esque expressions as common syntax.

ds| seems to work, deletes the surrounding | characters successfully, and cs|) also seems to work (changes them to other types of "surrounders"), as does cs)|.

However, ysi|, ci|, vi| all don't work.

tpope commented 1 year ago

Not a built-in, but you can create it yourself: see :help surround-customizing.

myarcana commented 1 year ago

Adding let g:surround_124 = "|\r|" (char2r("|") is 124) doesn't seem to change the behaviour of my editor. ysiw| still works just like before, but ci| still doesn't work

tpope commented 1 year ago

See :help text-objects. Specifically, note that it doesn't mention i| anywhere.

Kache commented 1 year ago

Adding a clarification b/c it wasn't clear to me right away: vim-surround doesn't define text objects like those, e.g. the same "issue" exists for , where you can ds, but not ci,.

However as mentioned in #305, a good alternative is vim-textobj-between (see: https://github.com/kana/vim-textobj-user/wiki).