Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce configuration option to disable adding spaces #378

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.markdown
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion plugin/surround.vim
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down