Add the 'L' item to 'cinoptions'. (Manuel Konig)
diff --git a/runtime/doc/indent.txt b/runtime/doc/indent.txt
index 410fe38..a1d4cb2 100644
--- a/runtime/doc/indent.txt
+++ b/runtime/doc/indent.txt
@@ -216,6 +216,19 @@
} } }
} } }
<
+ LN Controls placement of jump labels. If N is negative, the label
+ will be placed at column 1. If N is non-negative, the indent of
+ the label will be the prevailing indent minus N. (default -1).
+
+ cino= cino=L2 cino=Ls >
+ func() func() func()
+ { { {
+ { { {
+ stmt; stmt; stmt;
+ LABEL: LABEL: LABEL:
+ } } }
+ } } }
+<
:N Place case labels N characters from the indent of the switch().
(default 'shiftwidth').
@@ -464,13 +477,14 @@
The defaults, spelled out in full, are:
- cinoptions=>s,e0,n0,f0,{0,}0,^0,:s,=s,l0,b0,gs,hs,ps,ts,is,+s,c3,C0,
- /0,(2s,us,U0,w0,W0,m0,j0,)20,*70,#0
+ cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,ps,ts,is,+s,
+ c3,C0,/0,(2s,us,U0,w0,W0,m0,j0,J0,)20,*70,#0
Vim puts a line in column 1 if:
- It starts with '#' (preprocessor directives), if 'cinkeys' contains '#'.
- It starts with a label (a keyword followed by ':', other than "case" and
- "default").
+ "default") and 'cinoptions' does not contain an 'L' entry with a positive
+ value.
- Any combination of indentations causes the line to have less than 0
indentation.
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index ba8ac91..4082b0a 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1095,9 +1095,6 @@
Vim 7.3:
Patches to possibly include:
-- Patch for adding "J" flag to 'cinoptions': placement of jump label. (Manuel
- Konig, 2010 Feb 19) Update by Lech Lorens, Feb 22.
- Need another name, "J" is now used for Javascript.
- Patch for Python 3 support. (Roland Puntaier, 2009 Sep 22)
Includes changes for omnicompletion.
Needs some more testing.
diff --git a/src/misc1.c b/src/misc1.c
index 4b0ff6d..e34f033 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -6062,6 +6062,12 @@
int ind_open_left_imag = 0;
/*
+ * Spaces jump labels should be shifted to the left if N is non-negative,
+ * otherwise the jump label will be put to column 1.
+ */
+ int ind_jump_label = -1;
+
+ /*
* spaces from the switch() indent a "case xx" label should be located
*/
int ind_case = curbuf->b_p_sw;
@@ -6232,6 +6238,7 @@
int iscase;
int lookfor_break;
int cont_amount = 0; /* amount for continuation line */
+ int original_line_islabel;
for (options = curbuf->b_p_cino; *options; )
{
@@ -6277,6 +6284,7 @@
case '{': ind_open_extra = n; break;
case '}': ind_close_extra = n; break;
case '^': ind_open_left_imag = n; break;
+ case 'L': ind_jump_label = n; break;
case ':': ind_case = n; break;
case '=': ind_case_code = n; break;
case 'b': ind_case_break = n; break;
@@ -6339,6 +6347,8 @@
curwin->w_cursor.col = 0;
+ original_line_islabel = cin_islabel(ind_maxcomment); /* XXX */
+
/*
* #defines and so on always go at the left when included in 'cinkeys'.
*/
@@ -6348,9 +6358,11 @@
}
/*
- * Is it a non-case label? Then that goes at the left margin too unless JS flag is set.
+ * Is it a non-case label? Then that goes at the left margin too unless:
+ * - JS flag is set.
+ * - 'L' item has a positive value.
*/
- else if (!ind_js && cin_islabel(ind_maxcomment)) /* XXX */
+ else if (original_line_islabel && !ind_js && ind_jump_label < 0)
{
amount = 0;
}
@@ -7743,6 +7755,10 @@
/* add extra indent for a comment */
if (cin_iscomment(theline))
amount += ind_comment;
+
+ /* subtract extra left-shift for jump labels */
+ if (ind_jump_label > 0 && original_line_islabel)
+ amount -= ind_jump_label;
}
/*