-
Notifications
You must be signed in to change notification settings - Fork 139
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
Permit disabling softtabstop control, as softtabstop is a Vim-specific feature not supported by EditorConfig #198
Conversation
@inkarkat Great to hear from a wizard :) . Thanks for the PR! Just to confirm, |
@cxw42 As a longtime Vim user, I've so far relied on local vimrc indent settings and my own IndentConsistencyCop plugin. I've been aware (and supportive) of EditorConfig for a long time though; now a colleague of mine has introduced EditorConfig at work, so I've started using it, too. With enabled Your |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given two votes for removing the effect of sts
, I think it's reasonable to make that an option.
However, this change affects the ergonomics of Vim for every file edited to which the plugin applies edit and for which indent_style = space
. I think that, as a user, I would be very surprised if an update to EditorConfig changed how <BS>
worked (instead of one indent level, a single space, when indent_style = space
).
Would you please update this PR to keep the existing behaviour unless g:EditorConfig_sts_zero
(or something like that) is set before plugin load? Adding that option will (I think) give you what you need without surprising existing users.
Changes I am requesting:
- Functional change here
plugin/editorconfig.vim
: if the global is unset, set it to 0doc/editorconfig.txt
: document the option
Let me know your thoughts! Thanks very much!
Thanks very much indeed! 🎉 |
As the author of #137, I do not oppose this PR. ;) It's still not the way I would write it, but that should not be a blocker. (In short, I think -1 and 0 are both perfectly reasonable values for sts, and I wouldn't want EditorConfig to make that choice for me. I consider sts a UI feature, not an editing/filetype feature.) |
…} config The 'softtabstop' setting is meant to be used with a value that is different from the 'tabstop' setting (and 'tabstop' typically then kept at the default 8), and then renders the indent first with hard tabs, filling remaining differences with spaces. Though this has some nice editing characteristics (no messing with tabstop values but still getting cursor progressing to certain columns), it is quite specific to Vim and hasn't caught on elsewhere. Therefore, the EditorConfig spec doesn't support this feature. The existing implementation sets 'softtabstop' to the 'tabstop' / indent size, effectively turning off the mixed indenting completely. That is not wrong, and actually necessary so that backspace will delete one complete indent instead of a single space character when using spaces for indent. However, when hard tabs are configured and the user (maybe temporarily) manually adjusts the size of an indent by changing the 'tabstop' (and 'shiftwidth') values, suddenly, 'tabstop' is different from 'softtabstop', and Vim starts inserting the mix of tabs and spaces that the softtabstop feature is about! Since Vim 7.3.693, such discrepancy can be avoided via a special negative value. Also, some plugins or statuslines may wrongly interpret the positive 'softtabstop' value to indicate activation of the softtabstop feature, even though it's effectively off. This change is related to editorconfig#137; however, instead of dropping the modification of 'softtabstop' altogether, I think it's better to offer configuration options, separately for tab and space indents, as the effect is quite different. The default value of 1 maintains the existing behavior of setting 'softtabstop' equal to 'shiftwidth'; 0 will turn off 'softtabstop' (not recommended with spaces due to the strange backspace behavior, but in my opinion quite sensible for tab-based indents).
Picking up the argument from @chreekat in editorconfig#137, it can be argued that 'softtabstop' purely is a user experience feature and the EditorConfig plugin should not modify it at all. (This argument can be made since Vim 7.3.693, where a negative value makes 'softtabstop' automatically assume the value of 'shiftwidth'; a value of 0 disables the feature altogether. However, I think most users would rather see 'softtabstop' as one of the indent options, especially when positive values are assigned to it.) A special (empty) List configuration value can make the EditorConfig plugin skip the update of 'softtabstop'.
a7c6aff
to
fc190c9
Compare
Thanks @cxw42 for bringing up the issue with backspacing and space-indents! I've rarely used space-indenting, and almost forgot that Great that @chreekat approves and chimed in here as well; I hopefully have reworked my PR with a second commit to address your feedback as well. I think there should be two separate plugin config options; I've written almost too much documentation for these options, but I think most users will be fine with the defaults and those who do have a desire to tweak this need a bit of explanation, as Vim itself carries a lot of historic baggage and hard-to-understand documentation with it there. |
@inkarkat Thanks very much! The updates seem reasonable to me. I tried out the new code locally and it appears to work as described in the documentation :) . Happy Vimming! |
The
softtabstop
setting is meant to be used with a value that is different from thetabstop
setting (andtabstop
typically then kept at the default 8), and then renders the indent first with hard tabs, filling remaining differences with spaces. Though this has some nice editing characteristics (no messing with tabstop values but still getting cursor progressing to certain columns), it is quite specific to Vim and hasn't caught on elsewhere. Therefore, the EditorConfig spec doesn't support this feature.The existing implementation sets
softtabstop
to thetabstop
/ indent size, effectively turning off the feature completely. That is not wrong. However, Vim documents that the feature is turned off by a value of 0; a value equal totabstop
andshiftwidth
effectively turns off the feature as well. The difference matters when hard tabs are configured and the user (maybe temporarily) manually adjusts the size of an indent by changing thetabstop
(andshiftwidth
) values. Suddenly,tabstop
is different thansofttabstop
, and Vim starts inserting the mix of tabs and spaces that the softtabstop feature is about! Also, some plugins or statuslines may wrongly interpret the positivesofttabstop
value to indicate activation of the softtabstop feature, even though it's effectively off.This change is related to #137; however, instead of dropping the modification of
softtabstop
altogether, I think it's better to resetsofttabstop
to 0, to avoid the potential bad effects just mentioned. Users may have globally turnedsofttabstop
on, and that global value would then still be inherited into buffers under control of EditorConfig configurations.