:%s/function/&/gn
で、ファイル内に function がいくつあるか表示される。
キモは 置換フラグの n。これを指定すると置換は行われずにマッチの数を表示する。he :s で、
[n] Report the number of matches, do not actually substitute.
よって、
:%s/function/hogehoge/gn
としてもよいが、置換後の文字列は &、つまりマッチした文字列そのものにしておいたほうが無難。
:%s/function/&/gn
で、ファイル内に function がいくつあるか表示される。
キモは 置換フラグの n。これを指定すると置換は行われずにマッチの数を表示する。he :s で、
[n] Report the number of matches, do not actually substitute.
よって、
:%s/function/hogehoge/gn
としてもよいが、置換後の文字列は &、つまりマッチした文字列そのものにしておいたほうが無難。