Ultisnips: Latex snippets only work with .latex extension, not .tex

Created on 14 Apr 2018  路  7Comments  路  Source: SirVer/ultisnips

Expected behavior:

Snippets working in files with .tex extension, as it is the most popular extension for latex files.

can't reproduce duplicate

Most helpful comment

Thanks,
I added the line
let g:tex_flavor = "latex"
to my vimrc and it worked.
I don't know if it is the ideal solution. I don't know what a preamble is but for now, I'm satisfied.

All 7 comments

Can't reproduce:
image
Everything works in .tex just fine.
Seems like duplicate of #824. I will reopen it if your problem is different.

I don't know why they are working:
Here's some stuff from my vimrc:
Plug 'honza/vim-snippets' Plug 'SirVer/ultisnips' "ultisnips let g:UltiSnipsExpandTrigger='<c-j>' let g:UltiSnipsJumpForwardTrigger='<c-j>' let g:UltiSnipsJumpBackwardTrigger="<c-k>"

Did you read my explanations about tex filetype and plaintex filetype in #824 ?
Run :setf tex and try to expand begin stippet.

I've read it but didn't understand very well, I added the line
let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/bundle/vim-snippets/UltiSnips']
But it didn't seem to do the trick.

:setf tex worked on the .tex file.

Please read the documentation. You need paragraph 3.3 Snippet Search Path.

I added the line
let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/bundle/vim-snippets/UltiSnips']

This doesn't make sence to ultisnips, as it already knows where to look for snippets provided with vim-snippets plugin. But this is not related to your problem.

If you open empty .tex file it's filetype wil be plaintex. Wich means that Ultisnips will look for snippets for this filetype, an there is no snippets for this filetype in vim-snippets plugin. If your .tex file contains preamble, vim sets tex filetype, and UltiSnips searches for tex snippets. If you open empty .latex file, vim sets tex filetype, and your snippets are working here too.

Thanks,
I added the line
let g:tex_flavor = "latex"
to my vimrc and it worked.
I don't know if it is the ideal solution. I don't know what a preamble is but for now, I'm satisfied.

Please read the documentation. You need paragraph 3.3 Snippet Search Path.

I added the line
let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/bundle/vim-snippets/UltiSnips']

This doesn't make sence to ultisnips, as it already knows where to look for snippets provided with vim-snippets plugin. But this is not related to your problem.

If you open empty .tex file it's filetype wil be plaintex. Wich means that Ultisnips will look for snippets for this filetype, an there is no snippets for this filetype in vim-snippets plugin. If your .tex file contains preamble, vim sets tex filetype, and UltiSnips searches for tex snippets. If you open empty .latex file, vim sets tex filetype, and your snippets are working here too.

So what preamble should I add to mark a filetype I wanna use?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MikeDacre picture MikeDacre  路  3Comments

lx93uv picture lx93uv  路  6Comments

jonathf picture jonathf  路  6Comments

kirillbobyrev picture kirillbobyrev  路  4Comments

vanabel picture vanabel  路  7Comments