3

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).

:1,$-10fold
1
  • 4
    not possible via modelines. However should be possible using a Buf(Win)Enter autocommand Commented Sep 20, 2023 at 11:09

1 Answer 1

1

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

augroup FoldSpecificLog
  autocmd!
  autocmd BufRead /usr/bar/foo.csv 1,$-10fold
augroup END
1
  • 1
    Maybe an augroup instead of autocmd! ? Commented 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.