How do I count the number of times a particular word occurs in a

buffer? You can use the following set of commands to count the number of times a particular word occurs in a buffer:

    :let cnt=0

    :g/\/let cnt=cnt+1

    :echo cnt

This only counts the number of lines where the word occurs. You can also use the following command:

    :%s/\/&/gn

To count the number of alphabetic words in a file, you can use

    :%s/\a\+/&/gn

To count the number of words made up of non-space characters, you can use

    :%s/\S\+/&/gn

Read free Software Algorithms and Computer Science Books by CodeAhoy Learn.

Introduction to Recursion and Backtracking

Sorting Algorithms

Introduction to C Programming Language

And More...

Speak Your Mind