Other published solutions are great for certain line numbers. It often happens that you want to read above or below another file. In this case, reading the output of the head or tail is very fast. For example -
:r !head -20 xyz.xml
Will read the first 20 lines from xyz.xml to the current buffer, where the cursor
:r !tail -10 xyz.xml
Will read the last 10 lines from xyz.xml into the current buffer, where the cursor
Head and tail commands are extremely fast, so combining them can be much faster than other approaches for very large files.
:r !head -700030 xyz.xml| tail -30
Will read line numbers from 700000 to 700030 from the xyz.xml file to the current buffer
This operation should complete instantly, even for fairly large files.
raj Jul 10 '17 at 11:55 2017-07-10 11:55
source share