@@ -742,7 +742,14 @@ edit(
742742 mincol = curwin -> w_wcol ;
743743 validate_cursor_col ();
744744
745- if ((int )curwin -> w_wcol < mincol - curbuf -> b_p_ts
745+ if (
746+ #ifdef FEAT_VARTABS
747+ (int )curwin -> w_wcol < mincol - tabstop_at (
748+ get_nolist_virtcol (), curbuf -> b_p_ts ,
749+ curbuf -> b_p_vts_array )
750+ #else
751+ (int )curwin -> w_wcol < mincol - curbuf -> b_p_ts
752+ #endif
746753 && curwin -> w_wrow == W_WINROW (curwin )
747754 + curwin -> w_height - 1 - p_so
748755 && (curwin -> w_cursor .lnum != curwin -> w_topline
@@ -9329,23 +9336,31 @@ ins_bs(
93299336 */
93309337 if ( mode == BACKSPACE_CHAR
93319338 && ((p_sta && in_indent )
9332- || (get_sts_value () != 0
9339+ || ((get_sts_value () != 0
9340+ #ifdef FEAT_VARTABS
9341+ || tabstop_count (curbuf -> b_p_vsts_array )
9342+ #endif
9343+ )
93339344 && curwin -> w_cursor .col > 0
93349345 && (* (ml_get_cursor () - 1 ) == TAB
93359346 || (* (ml_get_cursor () - 1 ) == ' '
93369347 && (!* inserted_space_p
93379348 || arrow_used ))))))
93389349 {
9350+ #ifndef FEAT_VARTABS
93399351 int ts ;
9352+ #endif
93409353 colnr_T vcol ;
93419354 colnr_T want_vcol ;
93429355 colnr_T start_vcol ;
93439356
93449357 * inserted_space_p = FALSE;
9358+ #ifndef FEAT_VARTABS
93459359 if (p_sta && in_indent )
93469360 ts = (int )get_sw_value (curbuf );
93479361 else
93489362 ts = (int )get_sts_value ();
9363+ #endif
93499364 /* Compute the virtual column where we want to be. Since
93509365 * 'showbreak' may get in the way, need to get the last column of
93519366 * the previous character. */
@@ -9354,7 +9369,15 @@ ins_bs(
93549369 dec_cursor ();
93559370 getvcol (curwin , & curwin -> w_cursor , NULL , NULL , & want_vcol );
93569371 inc_cursor ();
9372+ #ifdef FEAT_VARTABS
9373+ if (p_sta && in_indent )
9374+ want_vcol = (want_vcol / curbuf -> b_p_sw ) * curbuf -> b_p_sw ;
9375+ else
9376+ want_vcol = tabstop_start (want_vcol , curbuf -> b_p_sts ,
9377+ curbuf -> b_p_vsts_array );
9378+ #else
93579379 want_vcol = (want_vcol / ts ) * ts ;
9380+ #endif
93589381
93599382 /* delete characters until we are at or before want_vcol */
93609383 while (vcol > want_vcol
@@ -10144,10 +10167,22 @@ ins_tab(void)
1014410167#endif
1014510168
1014610169 /*
10147- * When nothing special, insert TAB like a normal character
10170+ * When nothing special, insert TAB like a normal character.
1014810171 */
1014910172 if (!curbuf -> b_p_et
10173+ #ifdef FEAT_VARTABS
10174+ && !(p_sta && ind
10175+ /* These five lines mean 'tabstop' != 'shiftwidth' */
10176+ && ((tabstop_count (curbuf -> b_p_vts_array ) > 1 )
10177+ || (tabstop_count (curbuf -> b_p_vts_array ) == 1
10178+ && tabstop_first (curbuf -> b_p_vts_array )
10179+ != get_sw_value (curbuf ))
10180+ || (tabstop_count (curbuf -> b_p_vts_array ) == 0
10181+ && curbuf -> b_p_ts != get_sw_value (curbuf ))))
10182+ && tabstop_count (curbuf -> b_p_vsts_array ) == 0
10183+ #else
1015010184 && !(p_sta && ind && curbuf -> b_p_ts != get_sw_value (curbuf ))
10185+ #endif
1015110186 && get_sts_value () == 0 )
1015210187 return TRUE;
1015310188
@@ -10162,13 +10197,28 @@ ins_tab(void)
1016210197#endif
1016310198 AppendToRedobuff ((char_u * )"\t" );
1016410199
10200+ #ifdef FEAT_VARTABS
10201+ if (p_sta && ind ) /* insert tab in indent, use 'shiftwidth' */
10202+ {
10203+ temp = (int )curbuf -> b_p_sw ;
10204+ temp -= get_nolist_virtcol () % temp ;
10205+ }
10206+ else if (tabstop_count (curbuf -> b_p_vsts_array ) > 0 || curbuf -> b_p_sts > 0 )
10207+ /* use 'softtabstop' when set */
10208+ temp = tabstop_padding (get_nolist_virtcol (), curbuf -> b_p_sts ,
10209+ curbuf -> b_p_vsts_array );
10210+ else /* otherwise use 'tabstop' */
10211+ temp = tabstop_padding (get_nolist_virtcol (), curbuf -> b_p_ts ,
10212+ curbuf -> b_p_vts_array );
10213+ #else
1016510214 if (p_sta && ind ) /* insert tab in indent, use 'shiftwidth' */
1016610215 temp = (int )get_sw_value (curbuf );
1016710216 else if (curbuf -> b_p_sts != 0 ) /* use 'softtabstop' when set */
1016810217 temp = (int )get_sts_value ();
1016910218 else /* otherwise use 'tabstop' */
1017010219 temp = (int )curbuf -> b_p_ts ;
1017110220 temp -= get_nolist_virtcol () % temp ;
10221+ #endif
1017210222
1017310223 /*
1017410224 * Insert the first space with ins_char(). It will delete one char in
@@ -10193,7 +10243,13 @@ ins_tab(void)
1019310243 /*
1019410244 * When 'expandtab' not set: Replace spaces by TABs where possible.
1019510245 */
10246+ #ifdef FEAT_VARTABS
10247+ if (!curbuf -> b_p_et && (tabstop_count (curbuf -> b_p_vsts_array ) > 0
10248+ || get_sts_value () > 0
10249+ || (p_sta && ind )))
10250+ #else
1019610251 if (!curbuf -> b_p_et && (get_sts_value () || (p_sta && ind )))
10252+ #endif
1019710253 {
1019810254 char_u * ptr ;
1019910255#ifdef FEAT_VREPLACE
0 commit comments