etc:
// xxxx /* yyy */
---------->after command will change to
/* xxxx /* yyy */*/
it will cause compile error.
how can i change above mix sytle comment to /* xxxx yyy */
The requirements are vague to me. What do you want to change for
these kind of comments:
// xxx /* yyy */ /* zzz */
// xxx /* yyy */ bla /* zzz */
And your rationale for the change?
Best regards,
Yongwei
--
Wu Yongwei
URL: http://wyw.dcweb.cn/
// xxx /* yyy */ /* zzz */
------->
/* xxx yyy zzz */ or any other format even like this /* xxx { yyy } {
zzz } */
According to our company coding standard ,c++ style comment is forbidden
so we have to make this change.
wow , u have just awoke me , i will try to replace these comment in two
step :
1st form /* xxx /* yyy */ /* zzz */*/
2nd form /* xxx { yyy } { zzz }*/
ths~ :)
Maybe some one who has the solution which can do this in one step plz
tell me , thanks~~
Alick
Amazing! I was thinking of deleting this silly tip, and now you are asking
for it!
http://vim.wikia.com/wiki/VimTip1010
I did quite a lot of quick cleaning up on the tip. If you want to be super
cautious, you could click the "imported from" link and check that I didn't
leave anything useful out.
John
That silly tip was mine ~(_8(I) . I still the replace per line instead of
the :%s solution. If I can remember correctly, the %s solution had problems
with indented comments. Indented comments are handy if you use folding.
(Although the folding might be tuned to handle folding better, but hey, it
works).
The tip options is solution for the mentioned problem, though.
I think you should first replace the /* and */ after //, and then
replace //. Something like:
%s!//.*\zs/\*!{!
%s!//.*\zs\*/!}!
%s!//\(.*\)!/*\1 */!
The problem of these substitutions is that one needs to repeat the
first two steps until all instances replaced. Maybe there are better
ways.
Hi Frans! This thread proves I was wrong - there are still people needing to
convert from C++ to C style comments.
I hope you have a look at the tip in its new home (URL above) and see if you
can improve it.
John
The desire to do the conversion is not silly at all. If you compile
with -ansi -pedantic then the c++ style comments do a headloop. It is however
a far easier form of commenting, using only one initialisation with no shift
required. For the motor industry, MISRA compliant C programming is required.
That requires -ansi -pedantic. Importing generic code blocks with c++ style
commenting then requires a conversion.
Frans
This is GCC specific.
> It is however a far easier form of commenting, using only one
> initialisation with no shift required. For the motor industry, MISRA
> compliant C programming is required. That requires -ansi -pedantic.
> Importing generic code blocks with c++ style commenting then
> requires a conversion.
Let me be pedantic too :-). "//" is not only valid in C++, but also
valid in C99. GCC won't complain if you specify std=c99.
> Frans
OK. Sorry I was flippant in my remark - I was really referring to the whole
page, including the bunch of comments arguing about //... and /*...*/.
Moreover, I think the fact that I cleaned the tip, and quoted it to someone
wanting the info shows that I don't really think it was silly, and was just
being flippant (to those of us who don't need to deal with MISRA or
whatever, it does sound a little strange that someone would want to automate
the conversion of C++ to C comments).
BTW if I had to do that, I would take a copy of the files, then run the
regex from the comment in the tip, then carefully check a diff with the
originals.
John
No worries mate, we all start programming and think: "What's the big deal with
global variables?" (as an example that we don't always understand the full
reason why). Outlookmonkeys love to write their emails in a word document and
then post a mail saying: "see attachment" They cannot grasp that it is
irritating and cumbersome. What I'm saying is that it happens soooo often
that people voice their opionon without full comprehension of the reasons why
people do it so, that it not even remotely angers me. Hell, 3 years ago I
would've thought it anal to go on a tangent about the c/c++ style commenting.
> BTW if I had to do that, I would take a copy of the files, then run the
> regex from the comment in the tip, then carefully check a diff with the
> originals.
If the files are small enough, then it using :%s/..../..../c is also an
option.
Greets,
Frans
>No worries mate, we all start programming and think: "What's the big
deal with
>global variables?" (as an example that we don't always understand the
full
I actually liked most of the ideas MISRA promotes (mandates?), because I
tend to be a rather anal-retentive programmer myself. I like modules
and routines that're wholly self-contained, and don't rely on global
variables at all. Makes them that much easier to transplant into
different routines...
>reason why). Outlookmonkeys love to write their emails in a word
document and
>then post a mail saying: "see attachment" They cannot grasp that it is
>irritating and cumbersome. What I'm saying is that it happens soooo
often
"Gee, your attachment was corrupted. Seems to happen a *lot* for some
reason. Send it as normal mail next time..."
I don't do proprietary formats at all. Someone sends you a file in M$W9
and if you only got M$W8 or -7, you're hosed. I don't care it
OpenOffice or StarOffice can read M$ files, send normal f'n mail. How
hard is *that*?
What you describe is easy for the *sender*, but a royal pain in the ass
for *me*. Hell, maybe I'll just send 'em an ODF file then let *them*
worry about it. How's *that*?
"Outlookmonkeys" is right...
>that people voice their opionon without full comprehension of the
reasons why
>people do it so, that it not even remotely angers me. Hell, 3 years ago
I
>would've thought it anal to go on a tangent about the c/c++ style
commenting.
Hey, we *all* need a hobby...
"Therapy helps, but screaming obscenities is cheaper..."