Home Explore Blog CI



neovim

7th chunk of `runtime/doc/indent.txt`
6926b3549ba45a18607ecaa96082fb31ad4cb3238bc648fa0000000100000fa6
 like "wN"
	      only for the "if", "for" and "while" conditions.  If 0, defaults
	      to behaviour defined by the "(N" flag.  (default: 0).

		cino=(0			   cino=(0,ks >
		  if (condition1	    if (condition1
		      && condition2)		    && condition2)
		      action();			action();
		  function(argument1	    function(argument1
			   && argument2);	     && argument2);
<
							*cino-m*
	mN    When N is non-zero, line up a line starting with a closing
	      parenthesis with the first character of the line with the
	      matching opening parenthesis.  (default 0).

		cino=(s			  cino=(s,m1 >
		  c = c1 && (		    c = c1 && (
		      c2 ||			c2 ||
		      c3			c3
		      ) && c4;		    ) && c4;
		  if (			    if (
		      c1 && c2			c1 && c2
		     )			    )
		      foo;			foo;
<
							*cino-M*
	MN    When N is non-zero, line up a line starting with a closing
	      parenthesis with the first character of the previous line.
	      (default 0).

		cino=			  cino=M1 >
		  if (cond1 &&		    if (cond1 &&
			 cond2			   cond2
		     )				   )
<
				*java-cinoptions* *java-indenting* *cino-j*
	jN    Indent Java anonymous classes correctly.  Also works well for
	      Javascript.  The value 'N' is currently unused but must be
	      non-zero (e.g. 'j1').  'j1' will indent for example the
	      following code snippet correctly: >

		object.add(new ChangeListener() {
		    public void stateChanged(ChangeEvent e) {
			do_something();
		    }
		});
<
			*javascript-cinoptions* *javascript-indenting* *cino-J*
	JN    Indent JavaScript object declarations correctly by not confusing
	      them with labels.  The value 'N' is currently unused but must be
	      non-zero (e.g. 'J1').  If you enable this you probably also want
	      to set |cino-j|. >

		var bar = {
		    foo: {
			that: this,
			some: ok,
		    },
		    "bar":{
			a : 2,
			b: "123abc",
			x: 4,
			"y": 5
		    }
		}
<
								*cino-)*
	)N    Vim searches for unclosed parentheses at most N lines away.
	      This limits the time needed to search for parentheses.  (default
	      20 lines).

								*cino-star*
	`*N`    Vim searches for unclosed comments at most N lines away.  This
	      limits the time needed to search for the start of a comment.
	      If your `/* */` comments stop indenting after N lines this is the
	      value you will want to change.
	      (default 70 lines).

								*cino-#*
	#N    When N is non-zero recognize shell/Perl comments starting with
	      '#', do not recognize preprocessor lines; allow right-shifting
	      lines that start with "#".
	      When N is zero (default): don't recognize '#' comments, do
	      recognize preprocessor lines; right-shifting lines that start
	      with "#" does not work.

								*cino-P*
	PN    When N is non-zero recognize C pragmas, and indent them like any
	      other code; does not concern other preprocessor directives.
	      When N is zero (default): don't recognize C pragmas, treating
	      them like every other preprocessor directive.


The defaults, spelled out in full, are: >
	cinoptions=>s,e0,n0,f0,{0,}0,^0,L-1,:s,=s,l0,b0,gs,hs,N0,E0,ps,ts,is,+s,
			c3,C0,/0,(2s,us,U0,w0,W0,k0,m0,j0,J0,)20,*70,#0,P0

Vim puts a line in column 1 if:
- It starts with '#' (preprocessor directives), if 'cinkeys' contains '#0'.
- It starts with a label (a keyword followed by ':', other than "case" and
  "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.

==============================================================================
2. Indenting by expression				*indent-expression*

The basics for using flexible indenting are explained in section |30.3| of the
user manual.

If you want to write your own indent file, it must set the 'indentexpr'
option.  Setting the 'indentkeys' option is often useful.
See the $VIMRUNTIME/indent/README.txt file for hints.
See the $VIMRUNTIME/indent directory for examples.


REMARKS

Title: Cinoptions for Parentheses, Conditional Statements, Java, Javascript, Comments, and Pragmas
Summary
This section details 'cinoptions' for indenting based on parentheses, conditional statements ('if', 'for', 'while'), Java anonymous classes (jN), JavaScript object declarations (JN), and comment/pragma recognition (#N, PN). It includes options for limiting the search distance for unclosed parentheses and comments. It also shows the default values of cinoptions and how Vim handles lines in column 1 based on preprocessor directives and labels. Finally, it mentions indenting by expression using 'indentexpr' and 'indentkeys'.