Currently I have the line
:nnoremap <leader>c :w<CR>:!arara %<CR><CR>
in my $MYVIMRC
. If I press <leader>c
, it will save the current file and run the command arara
on it. However I would like its behavior to be the following:
Save the current file
IF the first line has the form "%!TeX root = <something>"
THEN run the command "arara <something>" instead
ELSE run "arara <current file>"
For this it is required that vim reads the first line of the current file to process it in a command. I don't know how or if this is possible since I am rather new to vimscript.
The above behavior is rather standard in TeX editors and I would like to emulate it in vim.
In case it is important, I am using neovim rather than plain vim.
pdflatex-pdflatex-biber-pdflatex-...
), I would have to copy and maintain it in each sub-file with the {files =[main.tex]} option. And then I would also like my solution to still work if I switch to other compilation programs like pure pdflatex instead of arara.