It is about time to start writing my thesis. For the occasion, I decided to move over vim (I was previously a user of Texpad).

I want to briefly describe my basic configuration in a blog post with the hope it could be useful to someone else in the future.

At first, I decided to use vimtex. To install such a plugin, I relied on vim-plug, a plugin manager for vim. The repository gives clear instructions on how to complete the process.

With the command below, I downloaded the plug.vim file in the autoload directory of vim.

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \

Alternatively, as suggested by the documentation itself, it is possible to automate such a task by editing the vim configuration file (~/.vimrc) and adding this snippet:

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC

Once the plugin manager was installed, I proceeded to install vimtex. The task is quite easy: I only needed to add the Plug 'lervag/vimtex' entry in the vimrc file like in the example below:

call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
call plug#end()

To conclude the installation, just eeload vimrc typing :source ~/.vimrc inside vim and then type :PlugInstall to install the plugin.

First time I opened vim after that, I incurred in the g:tex_flavor not specified error. Adding let g:tex_flavor = 'latex' to the vimrc file fixes this warning.

As a color scheme, I am a fun of dracula which I use on every IDE.
Again, I just added a new entry (Plug 'dracula/vim', { 'as': 'dracula' }) in the vimrc file and ran again :PlugInstall.

For the code completion, I first installed coc.nvim, an Intellisense engine for vim with the corresponding coc-vimtex extension for tex.

To visualize the PDF generated by LaTeX, I use Skim instead of Preview (easily installable via brew), since it supports forward and backward search.
To automatically show the PDF after compilation in Skim, I modified my vimrc configuration as follows:

let g:vimtex_view_method = "skim"
let g:vimtex_view_general_viewer
        \ = '/Applications/'
let g:vimtex_view_general_options = '-r @line @pdf @tex'

" This adds a callback hook that updates Skim after compilation        
augroup vimtex_compilation
    au User VimtexEventCompileSuccess call UpdateSkim()
augroup END

function! UpdateSkim()
    let l:out = b:vimtex.out()
    let l:tex = expand('%:p')
    let l:cmd = [g:vimtex_view_general_viewer, '-r']
    if !empty(system('pgrep Skim'))
    call extend(l:cmd, ['-g'])
    if has('nvim')
    call jobstart(l:cmd + [line('.'), l:out, l:tex])
    elseif has('job')
    call job_start(l:cmd + [line('.'), l:out, l:tex])
    call system(join(l:cmd + [line('.'), shellescape(l:out), shellescape(l:tex)], ' '))

This is more or less my basic configuration and a decent starting point for more advanced customizations. More (much more) can be achieved by looking at the vimtex documentation.

My environment currently looks like the pic below. I have a table on content opened on the left side to quickly jump amongst files. On the right side I keep Skim opened with the autocompile active.