Skip to content

Commit 30ddc05

Browse files
authored
Merge pull request #198 from inkarkat/disable-softtabstop
Add new globals g:EditorConfig_softtabstop_space and g:EditorConfig_softtabstop_tab to control how sts is set
2 parents 6bba259 + fc190c9 commit 30ddc05

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

doc/editorconfig.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,23 @@ max_line_length is set:
161161
<
162162
This option defaults to 0.
163163

164+
*g:EditorConfig_softtabstop_space*
165+
When spaces are used for indent, Vim's 'softtabstop' feature will make the
166+
backspace key delete one indent level. If you turn off that feature (by
167+
setting the option to 0), only a single space will be deleted.
168+
This option defaults to 1, which enables 'softtabstop' and uses the
169+
'shiftwidth' value for it. You can also set this to -1 to automatically follow
170+
the current 'shiftwidth' value (since Vim 7.3.693). Or set this to [] if
171+
EditorConfig should not touch 'softtabstop' at all.
172+
173+
*g:EditorConfig_softtabstop_tab*
174+
When tabs are used for indent, Vim's 'softtabstop' feature only applies to
175+
backspacing over existing runs of spaces.
176+
This option defaults to 1, so backspace will delete one indent level worth of
177+
spaces; -1 does the same but automatically follows the current 'shiftwidth'
178+
value. Set this to 0 to have backspace delete just a single space character.
179+
Or set this to [] if EditorConfig should not touch 'softtabstop' at all.
180+
164181
*g:EditorConfig_verbose*
165182
Set this to 1 if you want debug info printed:
166183
>

plugin/editorconfig.vim

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ if !exists('g:EditorConfig_disable_rules')
6060
let g:EditorConfig_disable_rules = []
6161
endif
6262

63+
if !exists('g:EditorConfig_softtabstop_space')
64+
let g:EditorConfig_softtabstop_space = 1
65+
endif
66+
67+
if !exists('g:EditorConfig_softtabstop_tab')
68+
let g:EditorConfig_softtabstop_tab = 1
69+
endif
70+
6371
" Copy some of the globals into script variables --- changes to these
6472
" globals won't affect the plugin until the plugin is reloaded.
6573
if exists('g:EditorConfig_core_mode') && !empty(g:EditorConfig_core_mode)
@@ -394,12 +402,18 @@ function! s:ApplyConfig(config) abort " Set the buffer options {{{1
394402
" value
395403
if a:config["indent_size"] == "tab"
396404
let &l:shiftwidth = &l:tabstop
397-
let &l:softtabstop = &l:shiftwidth
405+
if type(g:EditorConfig_softtabstop_tab) != type([])
406+
let &l:softtabstop = g:EditorConfig_softtabstop_tab > 0 ?
407+
\ &l:shiftwidth : g:EditorConfig_softtabstop_tab
408+
endif
398409
else
399410
let l:indent_size = str2nr(a:config["indent_size"])
400411
if l:indent_size > 0
401412
let &l:shiftwidth = l:indent_size
402-
let &l:softtabstop = &l:shiftwidth
413+
if type(g:EditorConfig_softtabstop_space) != type([])
414+
let &l:softtabstop = g:EditorConfig_softtabstop_space > 0 ?
415+
\ &l:shiftwidth : g:EditorConfig_softtabstop_space
416+
endif
403417
endif
404418
endif
405419

0 commit comments

Comments
 (0)