Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on removing comments from a C source file. Let's focus on multiline comments /* ... */ and ignore the inline ones (//)

The following command seems to work with (solaris) sed:


However in Vim (7.2) it only works if the whole comment is on one line. How can I make it so the .* spreads over multiple lines? I tried doing the follwing


but it didn't work ...

share|improve this question
up vote 3 down vote accepted

I believe you'd want


\_ tells it to include newlines in the following character set (well, ., anyway).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.