vim-surround icon indicating copy to clipboard operation
vim-surround copied to clipboard

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

Open Freed-Wu opened this issue 3 years ago • 2 comments

#!/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

Freed-Wu avatar Sep 27 '22 14:09 Freed-Wu

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

jiz4oh avatar Apr 20 '23 00:04 jiz4oh

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

Freed-Wu avatar Apr 20 '23 09:04 Freed-Wu