Currently I have the line
:nnoremap <leader>c :w<CR>:!arara %<CR><CR>
$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.