# How do I set XeLaTeX as my default engine?

Without considering your tex editor, in order to compile your tex file with xelatex, add %!TeX program = xelatex to the first line of your source code. Because according to this link, Vimtex supports two TeX directives: TeX root and TeX program. Please consider the following example:

%!TeX program = xelatex

\documentclass{report}
\usepackage{fontspec}

\begin{document}
This is an example.
\end{document}


The variable $pdf_mode is responsible for the engine used to generate pdfs. You have to set $pdf_mode to 5 if you want to use XeLaTeX. You can do that by adding the following line to your configuration file (i.e. $HOME/.latexmkrc): $pdf_mode = 5;


Possible values for \$pdf_mode are:

0 = no pdf
1 = pdflatex
2 = pdf from ps
3 = pdf from dvi
4 = lualatex
5 = xelatex


This is well documented in the manual, which you can access either with man latexmk or, with TeX Live, texdoc latexmk.