This commit is contained in:
cnlzxin 2024-05-19 14:06:38 +08:00 committed by GitHub
commit e88977f8f6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View file

@ -77,6 +77,12 @@ support:
Only the opening brackets—`[`, `{`, and `(`—add a space. Use a closing
bracket, or the `b` (`(`) and `B` (`{`) aliases.
Two new global variables have been added to toggle whether spaces are added
to the opening and closing brackets, respectively
let g:surround_insert_space_left = 1 " left: opening brackets
let g:surround_insert_space_right = 0 " right: closing brackets
## Contributing
See the contribution guidelines for

View file

@ -8,6 +8,9 @@ if exists("g:loaded_surround") || &cp || v:version < 700
endif
let g:loaded_surround = 1
let g:insert_space_left = get(g:, 'surround_insert_space_left', 1)
let g:insert_space_right = get(g:, 'surround_insert_space_right', 0)
" Input functions {{{1
function! s:getchar()
@ -237,7 +240,14 @@ function! s:wrap(string,char,type,removed,special)
let before = '('.fnc.' '
let after = ')'
elseif idx >= 0
let spc = (idx % 3) == 1 ? " " : ""
let pos = idx % 3
let spc = ""
if g:insert_space_left && pos == 1 " left brackets
let spc = " "
endif
if g:insert_space_right && pos == 2 " right brackets
let spc = " "
endif
let idx = idx / 3 * 3
let before = strpart(pairs,idx+1,1) . spc
let after = spc . strpart(pairs,idx+2,1)