1

I am looking for a tool, option, or regex to move trailing comments to above the line they describe. In other words I would like to turn this:

a = b; // Assign b to a

into this:

// Assign b to a
a = b;

I am currently using uncrustify to clean up a large code base, but it doesn't look like it has an option for this, nor could I find it in other tools, though I may have missed it somewhere. The code makes a lot of use of trailing comments, and for the most part they are randomly spaced and badly aligned.

kcghost
  • 256
  • 1
  • 11

1 Answers1

1

Try the following regex in Vim:

s:^\(.*\)\s\+\(//.*\):\2\r\1:
Alex
  • 9,891
  • 11
  • 53
  • 87