# GVim extremely slow with plugins for long docs

I am using gvim with vimtex (this) with UltiSnips (this) and with conceallevel set to 2.

I use the above set-up to write my LaTeX documents. In general, this is slow but if my document is large then this is extremely slow and laggy which hampers my productivity quite a bit. I am using a laptop with Intel Core i5-5200U CPU @ 2.20GHz × 2 with 8 GB RAM and my OS is Linux Mint 18 Cinnamon 64-bit

Is there anyway to speed things up? Here is a preview of my ~/.vimrc :

call plug#begin('~/.vim/plugged')

Plug 'lervag/vimtex'
Plug 'arcticicestudio/nord-vim'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'KeitaNakamura/tex-conceal.vim'
"Plug 'dylanaraps/wal.vim'

call plug#end()

set number
set guifont=Iosevka\ 14

"colorscheme wal
colorscheme nord

" Variables for UltiSnips
let g:UltiSnipsSnippetDirectories=["~/.vim/plugged/mysnippets/"]
let g:UltiSnipsEditSplit='tabdo'
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'

" Variables for vimtex
let g:tex_flavor='latex'
let g:vimtex_view_method='zathura'
let g:vimtex_quickfix_mode=2
"let g:vimtex_indent_enabled=

" Concealing Settings
set conceallevel=2
let g:tex_conceal='abdmg'
hi Conceal guibg=Black

" Keep build files separated from pdf in output
let g:vimtex_compiler_latexmk = {
\ 'build_dir' : 'build',
\}

" Disabling smart indenting
set nosmartindent

" Switching between tabs
nnoremap <C-Left> :tabprevious<CR>
nnoremap <C-Right> :tabnext<CR>
nnoremap <C-j> :tabprevious<CR>
nnoremap <C-k> :tabnext<CR>

The above set-up is quite nice for me except for the lagging vim. If this cannot be handled by vim then are there any other alternatives for the same? I assume that the problem is with vim because various other things run just fine on my laptop.

Edit : A file while I am working on and the lag is noticeable -

% !TEX program = xelatex

\documentclass[12pt]{article}

\PassOptionsToPackage{fleqn}{amsmath}
\PassOptionsToPackage{usenames,dvipsnames,svgnames,table}{xcolor}

%Extendable Arrow Hack : Garamond-Math.pdf
\usepackage{mathtools} %or extarrow
\makeatletter
\renewcommand{\relbar}{\symbol{"E010}\mkern-.2mu\symbol{"E010}\mkern1.8mu}
\renewcommand{\Relbar}{\symbol{"E011}\mkern-.2mu\symbol{"E011}\mkern1.8mu}
\makeatother

\usepackage[makeroom,thicklines]{cancel} % for showing mathematical expression going to 0 or infinity etc.

%mathtools : loads amsmath and if included after unicode-math then causes problems with underbrace etc.

\usepackage{amssymb}
\usepackage{bm} %for boldface math

\usepackage{braket}

\usepackage[math-style=TeX, bold-style=TeX]{unicode-math}
\setmainfont{EB Garamond}
\setmathfont{Garamond-Math.otf}[StylisticSet={6,10}]

%\usepackage[T1]{fontenc}
%\usepackage{garamondx}
%\usepackage[garamondx,cmbraces]{newtxmath}
%\usepackage{bm} %for boldface math
%\usepackage{anyfontsize}

\newcommand{\diff}{\mathop{}\!\mathrm{d}}

\usepackage[a4paper, scale=0.9]{geometry}

\usepackage{tcolorbox}

\title{\textcolor{Sepia}{:SUSY 1D Potential Well: \\Calculation of 2-pt \& 4-pt Correlators}}
\author{Nitin}
\date{}

\begin{document}
\begin{tcolorbox}
\maketitle
\end{tcolorbox}
%\par\noindent\rule[0.5cm]{\textwidth}{1pt}

Here, I present my calculations for 2-pt and 4-pt correlators for SUSY 1D Potential Well system. The primary reference here is $^{\cite{ramadevi}}$ where the authors have calculated the partner system corresponding to the regular 1D Potential Well which I briefly recount here.

The correlators we are considering here have basic forms as : ${\braket{[x(t_{1}),x(t_{2})]},\ \braket{[p(t_{1}),p(t_{2})]},\ \braket{[x(t_{1}),p(t_{2})]}}$. From the paper by Hashimoto et al. $^{\cite{hashimoto}}$ we get ${p_{nm} = \frac{1}{2} E_{nm} x_{nm}}$. This means that the first two are not independent and we can just calculate either one of those two and the other will be fixed from it.

\textcolor{Sepia}{\section{Supersymmetric 1D Potential Well}}

\begin{itemize}
\item The non-SUSY 1D Potential Well is defined as :
\begin{align}
V^{B}(x) = \left\{\begin{array}{ll}
0 \quad &\text{for } 0 \leq x \leq L \\
\end{array}\right\}
\end{align}
with the wavefunction and energy given by :
\begin{aligned} \psi_{n}^{B} = \sqrt{\frac{2}{L}}\ \text{sin} \left( \frac{(n+1)\pi}{L}x \right) \quad \text{and} \quad E_{n}^{B} = \frac{(n+1)^{2} \pi^{2} \hbar^{2}}{2m L^{2}} \text{ for } n \in \{0,1,2,...\} .\end{aligned}
For simplicity we will consider ${\hbar = L = 2m = 1}$ so we get :
\begin{align}
\psi_{n}^{B} = \sqrt{2}\ \text{sin}( (n+1) \pi x) \quad \text{and} \quad E_{n}^{B} = (n+1)^{2} \pi^{2} \text{ for } n \in \{0,1,2,...\}
.\end{align}

\item The supersymmetric partner system is derived in $^{\cite{ramadevi}}$ with results as given below :
\begin{align}
W(x) &= - \pi\ \text{cot}(\pi x) \nonumber \\
V^{F}(x) &= 2 \pi^{2}\ \text{cosec}^{2}(\pi x) \nonumber \\
E_{n}^{F} =  E_{n+1}^{B} &= \pi^{2} (n+2)^{2} \nonumber \\
\psi_{n}^{F}(x) &= \sqrt{\frac{2}{(n+2)^{2} - 1}} \left\{ (n+2)\ \text{cos} ((n+2) \pi x) - \text{cot}( \pi x)\ \text{sin}((n+2) \pi x) \right\}
\end{align}
with ${n \in \{0,1,2,...\}}$

\end{itemize}

\textcolor{Sepia}{\section{Calculation of 2-pt Correlator :  ${-\braket{x(t_{1}), p(t_{2}) }}$}}

\begin{itemize}

\item We have the correlator's definition as the negative of thermal expectation value of the commutator ${[x(t_{1}),p(t_{2})]}$:
\begin{aligned} C_{T}(t_{1},t_{2}) &= - \braket{[x(t_{1}),p(t_{2})]} = - \frac{1}{Z} \sum_{m}^{} e^{-\beta e_{m}} \braket{\psi_{m} | \braket{[x(t_{1}),p(t_{2})]} | \psi_{m}} .\end{aligned}

\item We work in the Heisenberg Picture where operators are represented as : ${\mathcal{O}_{H}(t) = e^{iHt} \mathcal{O}_{S} e^{-iHt}}$, where ${\mathcal{O}_{H}}$ represents operator ${\mathcal{O}}$ in Heisenberg Picture and ${\mathcal{O}_{S}}$ represents it in Schr\"odinger Picture. Hence, we use the same to obtain the following :
\begin{aligned} C_{T}(t_{1},t_{2}) &= - \frac{1}{Z} \sum_{m}^{} e^{-\beta E_{m}} \braket{ \psi_{m} | \left\{ x(t_{1}) p(t_{2}) - p(t_{2}) x(t_{2}) \right\} | \psi_{m} } \\ &= - \frac{1}{Z} \sum_{m}^{} e^{-\beta E_{m}} \braket{\psi_{m} | \left\{ e^{iHt_{1}} x e^{-iHt_{1}} e^{iHt_{2}} p e^{-iHt_{2}} - e^{iHt_{2}} p e^{-iHt_{2}} e^{iHt_{1}} x e^{-iHt_{1}} \right\} | \psi_{m}} \\ &= - \frac{1}{Z} \sum_{m}^{} e^{-\beta E_{m}} \braket{\psi_{m} | \left\{ e^{iHt_{1}} x e^{-iHt_{1}} \underbrace{ \sum_{k}^{} \ket{\psi_{k}} \bra{\psi_{k}}}_\text{Identity} e^{iHt_{2}} p e^{-iHt_{2}} - e^{iHt_{2}} p e^{-iHt_{2}} \underbrace{ \sum_{k}^{} \ket{\psi_{k}} \bra{\psi_{k}}}_\text{Identity} e^{iHt_{1}} x e^{-iHt_{1}} \right\} | \psi_{m}} \\ &= - \frac{1}{Z} \sum_{m}^{} \sum_{k}^{} e^{-\beta E_{m}} \left\{ \braket{\psi_{m} | e^{iHt_{1}} x e^{-iHt_{1}} | \psi_{k}} \braket{\psi_{k} | e^{iHt_{2}} p e^{-iHt_{2}} | \psi_{m}} - \braket{\psi_{m} | e^{iHt_{2}} p e^{-iHt_{2}} | \psi_{k}} \braket{\psi_{k} | e^{iHt_{1}} x e^{-iHt_{1}} | \psi_{m}} \right\} .\end{aligned}

\end{itemize}

\newpage
\begin{thebibliography}{99}

Kulkarni, A., Ramadevi, P. Supersymmetry. Reson 8, 28–41 (2003),
%Supersymmetry,''
%https://doi.org/10.1007/BF02835648

\bibitem{hashimoto}
K.~Hashimoto, K.~Murata, R.~Yoshii \href{http://arxiv.org/abs/1703.09435v1}{arXiv:1703.09435}

\end{thebibliography}
\end{document}

• It's a syntax problem, most likely. Does :syntax off speed things back up? You'll lose some nice features, but... you could also try turning off just conceal. But I find that usually the culprit in large documents is syntax highlighting – D. Ben Knoble May 11 at 22:57
• If syntax off fixes the problem, then you might be able to get the best of both worlds by tweaking the sync search distance. Try :syntax sync maxlines=100 This trades off some possible accuracy for speed. See :help :syn-sync-maxlines – Rich May 11 at 23:18
• @D.BenKnoble Sorry for late reply. I tried these but the effect is only marginally better. The lag is there even when I have a small document of only 100 lines or so! – Nitin Jun 2 at 1:49
• @Rich Could you please give another solution? I went down to as low as :syntax sync maxlines=25 but the performance improved by just a tiny bit and it's not really up to the mark :( – Nitin Jun 2 at 1:51
• 100 long lines, or short (80-100 cols) lines? An example would help. – D. Ben Knoble Jun 2 at 2:04