I would like vim
to detect and store the number of commented lines (prefixed with #
) from the start of a file and then use a variable with the stored value to change a vim-setting in a file-specific manner.
Example:
If I open this file:
# Comment here
# and here
file text starts here
I want the variable to store 2
, and then use that value to set which line to start highlighting at (specifically with csv_headerline=
in the csv-vim package). The number of commented lines would change from file to file.
I thought there might be a way to use autocmd
and set up my .vimrc
to have vim
look through the first few lines of the file before opening it, but I can't figure out how to do it.