Search code examples
searchcountvi

Search for string and get count in vi editor


I want to search for a string and find the number of occurrences in a file using the vi editor.


Solution

  • :g/xxxx/d
    

    This will delete all the lines with pattern, and report how many deleted. Undo to get them back after.