3

I have three related questions.

Prescript: I do have my curly brace line wrapping set to K&R style (at the end of the previous line) but that shouldn't be a material part of this, as whatever style is set in VS and Re#er should take over.

  1. Let's say an existing method looks like this:

    IEnumerable<ITransactionProcessingResult> ProcessTransactions(TransactionProcessingMethod method, IEnumerable<ITransaction> transactions, ISplineReticulator reticulator, AuthorizationToken authorizationToken) {
       return null;
    }
    

    What keyboard shortcut or menu option in Visual Studio 2015 (with ReSharper 10.0.1 installed) can I use to trigger "chopping" the parameter list so it automatically gets formatted like this? I already know about the options in VS and ReSharper that format long lines as one is typing—that's not what this is about. I'm looking for a keyboard shortcut to use: when my cursor is in the parameter list, I can press it to cause the parameters to toggle back and forth between one line and multiple lines.

    IEnumerable<ITransactionProcessingResult> ProcessTransactions(
       TransactionProcessingMethod method,
       IEnumerable<ITransaction> transactions,
       ISplineReticulator reticulator,
       AuthorizationToken authorizationToken
    ) {
       return null;
    }
    
  2. Is there anything similar that can trigger the reverse, of collapsing multi-line "chopped" parameters to a single line?

  3. Is there anything similar for method calls and their arguments, both chopping and unchopping?

I have searched through keyboard shortcuts in Visual Studio, and have searched online for VS and Resharper shortcuts but can't seem to find this option. Perhaps a custom script will need to come to the rescue...

P.S. I use the term "chop" because this is what the formatting options in ReSharper call it in the option "chop long lines". However, this action occurs only according to internal rules during certain text editing actions, and doesn't kick in on code that is already written and is not being edited.

A trick of editing, such as overtyping or deleting and retyping a character, that does cause this in at least some situations would be a useful stopgap measure, but I'm really looking for keyboard shortcuts.

ErikE
  • 48,881
  • 23
  • 151
  • 196
  • 1
    @magicandre1981 This is not a C# question. It's valid for any language that uses non-semantic white space and has some form of a parameter list that can go on multiple lines, or not. The C# example is just an example. – ErikE Jan 22 '16 at 17:50
  • yes, but the tags changes the code highlighting. Only black looks ugly. Revert the change to the first rev if you don't like it., – magicandre1981 Jan 22 '16 at 17:52
  • 1
    @magicandre1981 There, I added `` to the post (click edit to see). That gets the syntax highlighting. Good call to make it look better, there's just a way to do it without a `c#` tag. Thanks! – ErikE Jan 22 '16 at 17:55
  • Are [these](http://stackoverflow.com/a/4942145/1195056) what you're looking for? – krillgar Jan 22 '16 at 18:42
  • @krillgar Nope, those only format the document to meet the formatting options you have selected, but leaves alone lines that (chopped, or unchopped) already meet those requirements. I copied and pasted the above code into a new `.cs` file in my project, changed the data types to real ones that exist, and pressed those keyboard shortcuts a good half-dozen times. I tried both versions, and no reformatting ever occurred. Then I moved a curly brace down a line, pressed the same key combinations, and voilá, the curly brace moved back up. So the shortcuts operate but don't do what I want. – ErikE Jan 22 '16 at 18:52
  • ok, thanks, I didn't know about this language hack. I'll save this for later. – magicandre1981 Jan 23 '16 at 05:52

0 Answers0