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

Introduce configuration option to disable adding spaces

Open maze88 opened this issue 1 year ago • 6 comments

Although I'm familiar with the possibility of using closing brackets (as was added to the FAQ) to prevent adding spaces - I personally have no use cases that require such spaces, and reaching further (to the closing bracket) is less comfortable - thus I'd like the option to disable this feature entirely.

For this I have added a configuration option to disable/disclude such spaces like so:

let g:surround_insert_space = 0

(the default value will remain 1, so as not to break existing/expected behavior)

It's safe to assume that for such a common issue (https://github.com/tpope/vim-surround/issues/366, https://github.com/tpope/vim-surround/issues/363, https://github.com/tpope/vim-surround/issues/314, https://github.com/tpope/vim-surround/issues/303, https://github.com/tpope/vim-surround/issues/240, https://github.com/tpope/vim-surround/issues/205, https://github.com/tpope/vim-surround/issues/108, https://github.com/tpope/vim-surround/issues/27 ...), at least some of these other users could benefit from such a feature.

maze88 avatar Jun 17 '23 11:06 maze88

P.S. This is my first contribution to any VimScript project, I am warmly open to any feedback. I reviewed the Pathogen contribution guide referenced in the project's readme.

maze88 avatar Jun 17 '23 11:06 maze88

Would you consider adding a toggle? i.e. add whitespace on closing bracket instead of opening? Thanks!

rkochar avatar Jan 06 '24 20:01 rkochar

Would you consider adding a toggle? i.e. add whitespace on closing bracket instead of opening? Thanks!

I'm not sure exactly what you mean; the toggle I suggested is as a global setting

maze88 avatar Jan 07 '24 09:01 maze88

@maze88 my understanding is that your setting will enable disable whitespace being added with brackets. My suggestion (in addition to your flag) is that users can choose if whitespace is added in opening or closing brackets (toggle from opening bracket currently to closing bracket).

rkochar avatar Jan 08 '24 05:01 rkochar

@maze88 my understanding is that your setting will enable disable whitespace being added with brackets. My suggestion (in addition to your flag) is that users can choose if whitespace is added in opening or closing brackets (toggle from opening bracket currently to closing bracket).

Ahh, now I understood... Interesting concept - but I wouldn't be able to implement it with my minimal VimScript knowledge.

Perhaps create a separate fork and PR, to offer it?

maze88 avatar Jan 08 '24 08:01 maze88

@rkochar I had the same need, so I added two new options by referring to these codes in this PR.

let g:surround_insert_space_left = 1        " left: opening brackets
let g:surround_insert_space_right = 0       " right: closing brackets

here #387

cnlzxin avatar May 19 '24 06:05 cnlzxin