Word wrap for comments in C ++ in Qt Creator

What I'm looking for is really well explained in this thread I found. Out of him:

// This is my comment. But it has been edited // so now // some lines are long and others are // very short. // Personally, I find this exceedingly ugly and I really // can't tolerate it. However, having to manual fix this // sort // of thing is undesirable. 

The thread says that emacs has this function called Mq, where it will reformat the comments, while preserving the initial // .

Does Qt Creator have a similar feature? Or, if not, is there a (free) standalone program that would allow me to copy and paste comments into Qt Creator when I write them?

+4
source share
1 answer

Press Ctrl+E,R while the cursor is in the comments block. This adds and removes // as needed.

It has a quirk, though - if it is a comment on one line, it will not add // for new lines. The workaround is to add the line // below before pressing Ctrl+E,R

You also need to make sure that there is an empty line separating the comment from the code, otherwise it will also wrap the code.

This is bad:

 int a = 5; // something something // something something int b = 10; 

It will be wrapped incorrectly

 int a = 5; // something something // something something int b = 10; 

It's good:

 int a = 5; // something something // something something int b = 10; 
+6
source

All Articles