0

I wanted to write and edit a .tex document as fast as possible, so I followed this guide, but I can't get vimtex to work properly. I would like to have Vim hide characters like $,\[ and replace some commands like \bigcap with . I don't care about compiling, I use Overleaf for that, I would just like to have a smooth and fast way to edit tex files. I hope someone can kindly help me.

A screenshot of my Vim window:

enter image description here

And this is my _vimrc file:

filetype off
set shellslash
set rtp+=~\Vim\vimfiles\bundle\Vundle.vim
call vundle#begin('Vim/vimfiles/bundle')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

Plugin 'lervag/vimtex'
let g:tex_flavor='latex'
"let g:vimtex_view_method='zathura' DEACTIVATED because I don't need it
let g:vimtex_quickfix_mode=0
set conceallevel=1
let g:tex_conceal='abdmg'

call vundle#end()            " required
filetype plugin indent on    " required
  • 1
    Welcome to Vi and Vim! Just to rule out any other confounding factors, How to debug my vimrc – D. Ben Knoble Oct 31 '20 at 16:32
  • Hi, I'm sorry but I don't think that any of that is helpful in my case. – The Footprint Oct 31 '20 at 16:55
  • 1
    Actually, youve got a vimrc posted with irrelevant (we hope) code. If you can use those instructions to narrow down on a minimal vimrc that still reproduces your issue, it would make finding the problem that much easier. (You can edit once you find said minimal vimrc) – D. Ben Knoble Oct 31 '20 at 17:43
  • I changed the vimrc. I can't reduce it further because I am a noob, sorry. – The Footprint Oct 31 '20 at 19:52
  • 1
    FYI if you found a solution you should post it as an answer rather than edit the question. (It's perfectly fine to post an answer to your own question.) – B Layer Nov 2 '20 at 9:38
2

I wanted to write and edit a .tex document as fast as possible, so I followed this guide, but I can't get vimtex to work properly.

If you just want to edit a .tex document and not want to spend time learning tools, then I suggest you consider to use something like TeX maker. It should work well out of the box and the barrier to entry is very low.

If you want to use Vim with e.g. vimtex, you should expect to spend at least some time to learn to use the tools.

I would like to have Vim hide characters like $,[ and replace some commands like \bigcap with ∩. I don't care about compiling, I use Overleaf for that, I would just like to have a smooth and fast way to edit tex files. I hope someone can kindly help me.

This is actually not a part of vimtex (yet). Vimtex has so far relied on the syntax plugin developed by Dr. Chip, which provides the highlighting and conceal support. Vimtex have provided some additional improvements on the syntax, especially with regard to various packages.

So, my point is that your problem is not vimtex specific, but rather Vim (or neovim) specific.

And this is my _vimrc file: ...

I think the answer to your question is that you need to specify let g:tex_flavor = 'latex' to ensure that the filetype for tex files is tex (and not plaintex). In your screenshot, it seems you are looking at a minimal LaTeX file like this:

\[
    \bigcup
\]

Without specifying g:tex_flavor, such a file will be detected as a plaintex file, and so the conceal and syntax support will be very minimal.

  • 1
    That’s actually already in the vimrc, as far as i can tell. – D. Ben Knoble Nov 1 '20 at 14:32
  • I decided to use Vim because, if that guide I linked is correct, it can be much more efficient and practical than other methods. But that guide is intended for more advanced Vim and Linux users, so it's been quite misleading for me. For example, according to the guide it is vimtex that does the concealment. Is Dr. Chip syntax plugin integrated in vimtex? Also, I had already added g:tex_flavor to my _vimrc. – The Footprint Nov 1 '20 at 15:44
  • I solved it, look at the edit. Apparently I had to add KeitaNakamura concealment plugin? – The Footprint Nov 1 '20 at 16:50
  • 1
    @TheFootprint Yes, Vim can be a very efficient and practical tool, but it does take time to learn it properly. As a long time user I can strongly recommend it, but you should be aware it takes investment to learn how to use it. There is not really any shortcuts, you just have to take it step by step. Reg. vimtex and syntax: Vimtex has traditionally integrated around Dr. Chips syntax plugin. This is changing in the relatively near future, though. – Karl Yngve Lervåg Nov 1 '20 at 20:32
  • 1
    Thanks for the heads up Lervag, and thank you for writing vimtex by the way. I think the mistake was probably the missing line set encoding=utf-8, very hard to notice I believe. – The Footprint Nov 1 '20 at 21:03
1

By tweaking the _vimrc file I have managed to determine the likely cause of the issue: the (missing) setting set encoding=utf-8. Without it, neither the replacement of characters nor the concealment work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.