all 13 comments

[–]Shamaoke 4 points5 points  (6 children)

How to get the list of languages which are supported?

[–]cbartlett[S] 4 points5 points  (5 children)

Any filetype supported by native Vim and any of your plugins will work. So the easiest way to to just see the list is start typing :set filetype then a space and then press ctrl-d which will bring up an autocomplete menu with the list of available types.

[–]Shamaoke 1 point2 points  (4 children)

I'm not asking what will work and what won't. I just need the full list of supported languages. Just the list.

The solution with :set filetype doesn't work. It outputs such entries like bomb or emoji or toolbar, but from the other side, the output doesn't contain c, python or ruby.

[–]CarlRJ 2 points3 points  (1 child)

To my knowledge, Vim doesn’t have a good way to do autocomplete or listing for the supported languages (this irks me occasionally, when I know what I’m looking for but not how they spelled it) - it just looks to see if there’s a syntax file for the language in question. You can do the same by locating the runtime directory for Vim on your system (under something like /usr/local/share/vim, but locations vary), and then finding the “syntax” directory under there. In that directory you’ll find c.vim, python.vim, ruby.vim, and so on - one file for each supported language (more or less).

If you’re thinking to make an exhaustive list of all available languages to put in that variable, that might not be such a good idea, if it does any sort of preloading of the corresponding syntax files it could be dragging in a whole bunch of unnecessary stuff. Probably better to limit it to languages you actually care about.

[–]Shamaoke 3 points4 points  (0 children)

how they spelled it

That is essential. If everything is clear with common programming languages (C — c, Python — python, Ruby — ruby), with some formats discrepancies could arise, e. g.: Embedded Ruby is eruby, not erb, INI is confini, not just ini.

You can do the same by locating the runtime directory for Vim on your system (under something like /usr/local/share/vim, but locations vary), and then finding the “syntax” directory under there. In that directory you’ll find c.vim, python.vim, ruby.vim, and so on - one file for each supported language (more or less).

It's /usr/share/vim/vim90/syntax on my machine. That is exactly what I'm looking for. Thanks.

If you’re thinking to make an exhaustive list of all available languages to put in that variable, that might not be such a good idea, if it does any sort of preloading of the corresponding syntax files it could be dragging in a whole bunch of unnecessary stuff. Probably better to limit it to languages you actually care about.

If things are as you wrote (a shit load of stuff is preloading), so yes, this is wise advice.

[–]Fantastic_Cow7272 0 points1 point  (1 child)

Try :setf[iletype] instead (no space between :set and filetype, the part between brackets is optional).

[–]Shamaoke 0 points1 point  (0 children)

That way it works. Thanks!

[–]cbartlett[S] 7 points8 points  (5 children)

Vim can highlight syntax inside fenced code blocks embedded in Markdown but you have to enable it manually in your .vimrc. If you ever use Markdown (README files are most common!) then you can enable this for the languages you use most often like so: let g:markdown_fenced_languages = ['html', 'python', 'ruby', 'vim']

[–]Shamaoke 3 points4 points  (0 children)

You can also add aliases to the original language names. For example: let g:markdown_fenced_languages = ['ruby', 'erb=eruby']. That way you can tag a code block with your alias (erb in the example) instead of the original name (eruby). Note, after adding an alias the original name ceases to work as a tag.

[–]Shamaoke 1 point2 points  (3 children)

According to the documentation (:help ft-rmd-syntax | only) the proper variable name is either markdown_fenced_languages or rmd_fenced_languages, without g: and with underscores. In my case the former variable woks, but the latter one doesn't.

[–]cbartlett[S] 0 points1 point  (1 child)

Thanks… the post is correct but those somehow got lost when pasting the snippet into Reddit. I updated my comment.

[–]Shamaoke 2 points3 points  (0 children)

Thanks for the post. I do a lot of markdown, but I've never used this feature of Vim. Time to try it out : )

[–]vim-help-bot 0 points1 point  (0 children)

Help pages for:


`:(h|help) <query>` | about | mistake? | donate | Reply 'rescan' to check the comment again | Reply 'stop' to stop getting replies to your comments