I have a long .csv log file that I regularly append data to. I am usually interested in editing last 10 entries or so. I suppose vim modelines do not support Ex commands due to security reasons. Is there a workaround to make this Ex command a modeline in vim so that whenever the specific .csv file is opened, it shows only last 10 entries (like head but in vim).

  • 2
    not possible via modelines. However should be possible using a Buf(Win)Enter autocommand Sep 20, 2023 at 11:09

1 Answer 1


Suppose your file is /usr/bar/foo.csv I would do:

augroup FoldSpecificLog
  autocmd BufRead /usr/bar/foo.csv 1,$-10fold
augroup END
  • 1
    Maybe an augroup instead of autocmd! ?
    – D. Ben Knoble
    Sep 20, 2023 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.