Opening first few lines of a huge file with VS Code — Alex Brown

I’m currently doing some work looking at the GeoNames dataset.
allCountries.txt is around 1.5gb, which is pretty large, and certainly too large to open up in vscode for a quick look.

However, I found I could use command, which reads the first n lines of a file, and pipe the output to code - (which is the command for opening vs code and reading the output from another program)

For example:

$ head -3 allCountries.txt | code -

This opens the first 3 lines of allCountries.txt in vs code. Handy!

Originally published at on July 15, 2019.

Freelance / contract .net developer

Love podcasts or audiobooks? Learn on the go with our new app.