> Er, again, what's the deal with sts=-1 ?

sts=-1 would mean that sts takes on the same value as the shiftwidth.

This means you can change your shiftwidth and have the softtabstop change 
automatically. I (and I imagine most users with sts on) want the softtabstop to 
be one shiftwidth wide, but I often forget to update it.

The most common use case is deleting multiple spaces at a time. Imagine &sw=4 
and &sts=4 and you have a file with 'expand' tab. You 'set sw=8'. Now when your 
cursor is sitting behind 16 spaces and you hit backspace you expect 8 spaces to 
be deleted, but only 4 are deleted because you forgot to update 'sts'. This is 
incredibly annoying.

> So is sw=-1 (not needed, for consistency).

sw=0 has a similar effect to sts=-1, i.e. sw=0 makes sw take on the same value 
as tabstop. It's a bit strange to have one start falling back on the '-1' value 
and the other on the '0' value, which is why I put the second patch up; it 
makes sw behave a little more consistently with sts. I'm not sure it's a good 
idea, but it's something to think about.

By the way, this version fixes a documentation error in the above patch:

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff -r 04592728474a runtime/doc/options.txt
--- a/runtime/doc/options.txt	Fri Sep 21 14:54:30 2012 +0200
+++ b/runtime/doc/options.txt	Wed Oct 03 15:16:39 2012 -0700
@@ -6383,6 +6383,7 @@
 	of 8, while being able to edit like it is set to 'sts'.  However,
 	commands like "x" still work on the actual characters.
 	When 'sts' is zero, this feature is off.
+	When 'sts' is negative, the value of 'shiftwidth' is used.
 	'softtabstop' is set to 0 when the 'paste' option is set.
 	See also |ins-expandtab|.  When 'expandtab' is not set, the number of
 	spaces is minimized by using <Tab>s.
diff -r 04592728474a src/edit.c
--- a/src/edit.c	Fri Sep 21 14:54:30 2012 +0200
+++ b/src/edit.c	Wed Oct 03 15:16:39 2012 -0700
@@ -8885,7 +8885,7 @@
 	 */
 	if (	   mode == BACKSPACE_CHAR
 		&& ((p_sta && in_indent)
-		    || (curbuf->b_p_sts != 0
+		    || (get_sts_value() != 0
 			&& curwin->w_cursor.col > 0
 			&& (*(ml_get_cursor() - 1) == TAB
 			    || (*(ml_get_cursor() - 1) == ' '
@@ -8901,7 +8901,7 @@
 	    if (p_sta && in_indent)
 		ts = (int)get_sw_value();
 	    else
-		ts = (int)curbuf->b_p_sts;
+		ts = (int)get_sts_value();
 	    /* Compute the virtual column where we want to be.  Since
 	     * 'showbreak' may get in the way, need to get the last column of
 	     * the previous character. */
@@ -9590,7 +9590,7 @@
      */
     if (!curbuf->b_p_et
 	    && !(p_sta && ind && curbuf->b_p_ts != get_sw_value())
-	    && curbuf->b_p_sts == 0)
+	    && get_sts_value() == 0)
 	return TRUE;
 
     if (stop_arrow() == FAIL)
@@ -9606,8 +9606,8 @@
 
     if (p_sta && ind)		/* insert tab in indent, use 'shiftwidth' */
 	temp = (int)get_sw_value();
-    else if (curbuf->b_p_sts > 0) /* use 'softtabstop' when set */
-	temp = (int)curbuf->b_p_sts;
+    else if (curbuf->b_p_sts != 0) /* use 'softtabstop' when set */
+	temp = (int)get_sts_value();
     else			/* otherwise use 'tabstop' */
 	temp = (int)curbuf->b_p_ts;
     temp -= get_nolist_virtcol() % temp;
@@ -9635,7 +9635,7 @@
     /*
      * When 'expandtab' not set: Replace spaces by TABs where possible.
      */
-    if (!curbuf->b_p_et && (curbuf->b_p_sts || (p_sta && ind)))
+    if (!curbuf->b_p_et && (get_sts_value() || (p_sta && ind)))
     {
 	char_u		*ptr;
 #ifdef FEAT_VREPLACE
diff -r 04592728474a src/option.c
--- a/src/option.c	Fri Sep 21 14:54:30 2012 +0200
+++ b/src/option.c	Wed Oct 03 15:16:39 2012 -0700
@@ -8509,11 +8509,6 @@
 	    p_window = Rows - 1;
     }
 
-    if (curbuf->b_p_sts < 0)
-    {
-	errmsg = e_positive;
-	curbuf->b_p_sts = 0;
-    }
     if (curbuf->b_p_ts <= 0)
     {
 	errmsg = e_positive;
@@ -11429,3 +11424,13 @@
 {
     return curbuf->b_p_sw ? curbuf->b_p_sw : curbuf->b_p_ts;
 }
+
+/*
+ * Return the effective softtabstop value for current buffer, using the
+ * 'tabstop' value when 'softtabstop' is zero.
+ */
+    long
+get_sts_value()
+{
+    return curbuf->b_p_sts < 0 ? get_sw_value() : curbuf->b_p_sts;
+}
diff -r 04592728474a src/proto/option.pro
--- a/src/proto/option.pro	Fri Sep 21 14:54:30 2012 +0200
+++ b/src/proto/option.pro	Wed Oct 03 15:16:39 2012 -0700
@@ -57,4 +57,5 @@
 int file_ff_differs __ARGS((buf_T *buf, int ignore_empty));
 int check_ff_value __ARGS((char_u *p));
 long get_sw_value __ARGS((void));
+long get_sts_value __ARGS((void));
 /* vim: set ft=c : */

Raspunde prin e-mail lui