I’m trying to set up Vim to detect when a .tex file contains the command ‘\usepackage{sagemath}’, and run a command accordingly. I’ve gotten to
:au BufReadPost,BufWritePost *.tex TTarget sagepdf
but that will fire for all .tex files, which isn’t what I want.
Theres an example in my filetype.vim on how to destinguish html types. You can easily modify to suit your logic. Note the getline(n) =~ lines