tpope / vim-surround

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

Home Page:https://www.vim.org/scripts/script.php?script_id=1697

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug] g:surround_{char2nr('\')} will conflict with built-in `cst`

Freed-Wu opened this issue · comments

commented
#!/usr/bin/env -S vi test.vim + -u
" $ uname -r
" 5.19.7-arch1-1
" $ has
" ✓ vi 0.7.2
" $ cat test.vim
set runtimepath=$VIMRUNTIME
set runtimepath+=~/.local/share/nvim/repos/github.com/tpope/vim-surround
let g:surround_{char2nr('<')} = "< \r >"
" $ cat coc-settings.json
" $ chmod +x test.vim
" $ ./test.vim
" <div>Yo!*</div>

Actual behaviour

Type fYcst<

Screenshot from 2022-09-27 22-11-56

Expected behaviour

Type fYcst<p>

Screenshot from 2022-09-27 22-12-17

commented

I can complete this by let g:surround_{char2nr('<')} = "<\1<: \1>\r</\1\1>"

commented

Because

  • cs}{ will change {test} to { test }
  • cs][ will change [test] to [ test ]
  • cs)( will change (test) to ( test )

So I hope:

  • cs>< will change <test> to < test >

However it will conflict with cst<.