Currently Available: Need a skilled Software Developer for your next project?
Categories
LLM Software Development

Finding Long Files for Better Cursor IDE Performance

As a developer working with Cursor IDE, you've probably run into the line limit issue. Cursor has limitations on how large files can be for effective in-context usage, and when files get too long, you lose some of the IDE's most powerful features.

The solution? Refactor those unwieldy files into more manageable chunks. But first, you need to find them.

Here's a simple bash one-liner that will help you identify all those files in your repo that are exceeding reasonable line counts, while intelligently skipping over dependency directories like node_modules and vendor:

find . -type f -not -path "*/node_modules/*" -not -path "*/vendor/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*" | xargs wc -l | grep -v "total$" | awk '$1 > 100 {print $1 " lines: " $2}' | sort -nr

Different Thresholds for Different Needs

Depending on your project and Cursor's specific limits, you might want to adjust the threshold. Here are ready-to-use commands for various line counts:

Files with more than 100 lines:

find . -type f -not -path "*/node_modules/*" -not -path "*/vendor/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*" | xargs wc -l | grep -v "total$" | awk '$1 > 100 {print $1 " lines: " $2}' | sort -nr

Files with more than 300 lines:

find . -type f -not -path "*/node_modules/*" -not -path "*/vendor/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*" | xargs wc -l | grep -v "total$" | awk '$1 > 300 {print $1 " lines: " $2}' | sort -nr

Files with more than 500 lines:

find . -type f -not -path "*/node_modules/*" -not -path "*/vendor/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*" | xargs wc -l | grep -v "total$" | awk '$1 > 500 {print $1 " lines: " $2}' | sort -nr

Files with more than 750 lines:

find . -type f -not -path "*/node_modules/*" -not -path "*/vendor/*" -not -path "*/.git/*" -not -path "*/dist/*" -not -path "*/build/*" | xargs wc -l | grep -v "total$" | awk '$1 > 750 {print $1 " lines: " $2}' | sort -nr

How It Works

This command does several things:

  1. Uses find to locate all files while excluding common dependency directories
  2. Pipes them to wc -l to count lines in each file
  3. Filters out the summary "total" line with grep
  4. Uses awk to filter for files with more than X lines and format the output nicely
  5. Sorts them in descending order, so your longest files appear at the top

Once you've identified your longest files, you can start breaking them down into more modular components. Your Cursor IDE experience will improve dramatically, as will your code architecture!

What I'm building

Delegate tasks. Get software.

Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.

Take a look at vroni.com

Subscribe to my newsletter

Get new posts when I publish them.

I respect your privacy. Unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *