You could use !cp /dev/null %
, to truncate the currently viewed file. But as others have noted, it may not work correctly (e.g. if the application writing to the file holds the file open instead of opening/writing/closing for each entry). You might also try !mv -f % %.old && cp /dev/null %
, which will move the file out of the way then recreate it.
Either way, I see some strange behavior from less when trying these. (R does not refresh from disk, G does not seek to and display the current EOF (usually used to “pull in” new lines without going into ‘tail mode’), hqG reads in new lines from the file, but appends the entire contents of the file to the end of the buffer instead of just adding the new lines to the end (file has lines 1, then 1/2, then 1/2/3, etc. over time, less might show 1/1/1/2/1/2/1/2/3/1/2/3/1/2/3/4/1/2/3/4/1/2/3/4/5 if I was doing “hqG” twice after every new line)).
These same problems seem to happen with the “use v to truncate-by-editor” method, too.