简体   繁体   中英

How do I check if a file is empty using vimscript?

I have written my own linter in vimscript which lints a file using an external linting tool, and then reads the output into the quickfix window. I want to echo a message if there were no errors, but how can I check if that file is empty to do this?

Usually there's no need to check if temporary file is filereadable() . So only this should be enough:

if getfsize(tempname) < 1
    throw "cannot read temporary file"
endif

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM