diff --git a/README.markdown b/README.markdown index d2a5c29..06a3ff2 100644 --- a/README.markdown +++ b/README.markdown @@ -77,6 +77,9 @@ support: Only the opening brackets—`[`, `{`, and `(`—add a space. Use a closing bracket, or the `b` (`(`) and `B` (`{`) aliases. +Alternatively, to _completely disable_ adding of spaces (even with opening +brackets) - then one may set `let g:surround_insert_space = 0`. + ## Contributing See the contribution guidelines for diff --git a/plugin/surround.vim b/plugin/surround.vim index 8a4016e..49b31b4 100644 --- a/plugin/surround.vim +++ b/plugin/surround.vim @@ -7,6 +7,7 @@ if exists("g:loaded_surround") || &cp || v:version < 700 finish endif let g:loaded_surround = 1 +let g:surround_insert_space = get(g:, 'surround_insert_space', 1) " Input functions {{{1 @@ -237,7 +238,7 @@ function! s:wrap(string,char,type,removed,special) let before = '('.fnc.' ' let after = ')' elseif idx >= 0 - let spc = (idx % 3) == 1 ? " " : "" + let spc = (idx % 3) == 1 && g:surround_insert_space ? " " : "" let idx = idx / 3 * 3 let before = strpart(pairs,idx+1,1) . spc let after = spc . strpart(pairs,idx+2,1)