- Published on
Today I Learned: Counting Lines of Code in a Project with Neovim
- Authors

- Name
- Mehdi Akiki
Today, I wanted to get a quick count of lines of code (LOC) in a large project I’m working on. If you’re using Neovim like I am, there's a straightforward way to do this without leaving the editor. The trick combines the find and wc (word count) commands, run directly from Neovim.
Here’s how:
The Command
find . -name '*.ext' -type f | xargs wc -l
Explanation:
find . -name '*.ext' -type f: This part of the command recursively searches through the current directory (.) for files that match a specific extension, like*.jsfor JavaScript files. Replace*.extwith the file extension of your choice. If you want to include all files, use ``*`.xargs wc -l: Thexargscommand takes the output fromfindand applies thewc -lcommand to each file.wc -lcounts the number of lines in each file and then provides a total.
Running in Neovim
To run this directly in Neovim, open the command mode by typing : and add an exclamation mark ! to run shell commands:
:!find . -name '*.ext' -type f | xargs wc -l
This outputs the line count directly in Neovim, keeping everything in one place.
I build and scale reliable production systems. Open to full-time and freelance work with U.S.-based teams that value ownership and execution.
Got something in mind?
Book a Discovery Call