Visual Studio regex or macro to turn block of code into one-liner -



Visual Studio regex or macro to turn block of code into one-liner -

is there way in visual studio editor reformat block of code - e.g. properties or other mulitline block of code - one-liner? have text editor setting 'leave block on single line', while may keep code on single line not reformat single line on format document/selection. have tried replace using various regex patterns, , may find line endings, can't delete (\n , subsequent whitespace on next line) , move next line up.

i tip on how reformat this:

public int age { { homecoming age; } }

into one-liner:

public int age { { homecoming age; } }

anyone macros or replace using regex pattern?

here's ugly regex solution:

replace pattern:

^(\s*(?:(?:public|private|protected|internal|static|virtual|override|new)\s+)\s+\s+\s+)[\s\r\n]*\{[\s\r\n]*get[\s\r\n]*\{\s*(return\s+.+;)[\s\r\n]*\}[\s\r\n]*\}

with this:

$1 { { $2 } }

for reason vs seems not include [\r\n] in \s should.

but since solution ugly, should know resharper can reformat code (with iths code cleanup feature) , highly customizable.

regex visual-studio macros

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -