← til

Opening lines from the log file with Vim

October 25, 2020

I'm sure a lot of people had the amazing experience of opening a long log file with Vim.

However, most of the time, the log file is opened to read something from its end. The log file is rarely opened to figure something out from the middle or beginning of it.

Well, Vim supports piping text into it from stdin. So, in this case, instead of opening a log file with thousands upon thousands of lines, you can just pipe the last 500 lines to it to open it rapidly:

tail -n 500 log/development.log | vim -
@shime_sh Hrvoje Šimić
0 kudos