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

Comments (1)


Pepsh Pepshinsky

Let’s see you to :help viminfo-file-name (option -i) :set viminfofile=NONE


Speak Your Mind