I'm trying to obtain the number of lines matching a pattern, from a function. I would like the cursor not to be moved at all during the process.
In this case, non-empty and non-comment lines. Here's what I have so far:
function! CountRealLines()
:%s/^[^$,\"]//gn
endfunction
This displays the expected result, but I'm not sure how to return the count value (rather than printing the default message).
I also tried:
substitute(): I can't seem to make it work like the:scommand in this case.search(): It could be looped, but I think there must be a better way to go.