Bug 7733 - Indentation Options
Summary: Indentation Options
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Text Editor ()
Version: 4.0
Hardware: PC Mac OS
: Normal enhancement
Target Milestone: ---
Assignee: Mike Krüger
Depends on:
Reported: 2012-10-08 14:29 UTC by Jonathan Pryor
Modified: 2016-06-07 08:03 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jonathan Pryor 2012-10-08 14:29:54 UTC
Short version: I want vim `set cindent` with the default cinoptions:


In particular, the changes I want from the current default autoindent support is as follows:

	(N    When in unclosed parentheses, indent N characters from the line
	      with the unclosed parentheses.  Add a 'shiftwidth' for every
	      unclosed parentheses.  When N is 0 or the unclosed parentheses
	      is the first non-white character in its line, line up with the
	      next non-white character after the unclosed parentheses.
	      (default 'shiftwidth' * 2).

Meaning, if I'm writing an `if` block:

    if (foo
           ^ cursor

and I continue the `if` expression across multiple lines, the expression should be indented by an additional tab stop:

    foo (foo &&
            bar &&
            baz) {

Method call arguments, when line wrapping, should be indented by two tab-stops, NOT indented to align with the '(' (not sure which cinoption this is, but this is how vim behaves...):

            "Format String{0}",
    //  ^   ^ tab stops

This is how MonoDevelop already does things when you enter a newline immediately after the '('. HOWEVER, when the first argument is on the same line as the method name, this should CONTINUE to be the case:

    // DESIRED
    Console.WriteLine("Format String{0}",
    //  ^   ^ tab stops

    // CURRENT
    Console.WriteLine("Format String{0}",

The reason that I find the current behavior to be undesirable is that frequently the method name can (and will!) change (e.g. refactoring), but the argument list on following lines will not change. The result is that things look WRONG:

    // CURRENT, post-refactoring
    LogMessage("Format String{0}",

Things no longer line up properly. By ALWAYS indenting by two indents and not aligning to the '(', surrounding code doesn't need to be fixed during refactoring, minimizing the number of whitespace-only changes that need to be reviewed in the `git diff`. This also makes indentation more consistent, and makes things look nicer (imho).

The "two-tabstop" indent is, unfortunately, variable; the intent is to indent things to be distinct from following lines, but within nested expressions only one additional tabstop should be required:

    //  ^   ^   ^   ^   ^   ^   ^   ^ tab stops

In the above, the "outermost" Console.WriteLine() invocation has arguments indented by two tabstops, while the nested MethodInvoke() invocation only has its arguments indented by one additional tabstop.

This also applies to within `if` conditional expressions:

	uN    Same as (N, but for one level deeper.  (default 'shiftwidth').

		cino=			  cino=u2
		  if (c123456789	    if (c123456789
			  && (c22345		    && (c22345
			      || c3))		      || c3))

It applies for any use of '(', not just method invocations, but I find method invocations to be most common.
Comment 3 Mike Krüger 2016-06-07 08:03:28 UTC
We're now tied to the vs.net indentation system which doesn't support this indentation style.