开发者

vim regex to match inline comments

开发者 https://www.devze.com 2023-03-10 03:13 出处:网络
Assuming the following sample inline comment: /* function newMethodName (int bar, String s) { int i = 123;

Assuming the following sample inline comment:

/*
function newMethodName (int bar, String s) {
   int i = 123;
}
s/\<foo\s*(/newMethodName (/g
*/

How would I match and replace such that it would, essentially, become uncommented. I got this far before giving up.

:%s/\/\*\(\_.\)*\*\//\1/

Solution

:%s/\/\*\(\开发者_JAVA技巧_.*\)\*\//\1/


Your capture group ( ) is capturing one character or newline. Put the following * inside so that \1 replacement gets the whole string rather than just the first character.

0

精彩评论

暂无评论...
验证码 换一张
取 消