1

I want to remove a multi line comment in vim:

/**
 * Factory for creating [MainViewModel]
 *
 * @param arg the repository to pass to [MainViewModel]
 */

I tried

%s,/\*.*\*/,,gc

but it doesn't work for multiple lines and

s,/\*\_.*\*/,,gc

removes whole content inside First comment's beginning and last comment's ending.

2

This works:

%s,/\*\_.{-}\*/,,g

\_ includes newlines in the following character set.

{-} instead of * tells vim to be non-greedy in matching.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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