Vim supports syntax highlighting for embedded languages or fenced code in markdown (
However, you usually want that other vim settings and mappings are adjusted for embedded languages as well. These are for example
- load/unload ftplugins containing settings for example for
b:match_wordsused by matchit's
commentstring(e.g. for vim-commentary)
- square bracket motions (e.g. done in
- folds (
- indentation scripts in
- formatting (
formatprgor dedicated plugins autoformat, neoformat)
- 'intellisense' completion (
omnifuncor dedicated plugins ycm, deoplete, ncm2)
- linting (run compiler for code region or dedicated plugins ale, neomake or syntastic)
- ft snippets (ultisnips or snipmate)
Plugins I know which are dedicated to this or have builtin support are
- vim-context-commentstring (defines autocmd for the event
CursorMovedand uses the current syntax group to adjust the
- nvim-ts-context-commentstring Neovim treesitter plugin for setting the commentstring based on the cursor location in a file.
- tcomment (see
- ncm2 subscopes, e.g. https://github.com/ncm2/ncm2-markdown-subscope
- context_filetype.vim, e.g. for deoplete
It is one thing to adjust a single setting as done by https://github.com/suy/vim-context-commentstring but I miss support for the adjustments done in
$VIMRUNTIME/ftplugin and the
Afaik, this is something which vim does not really cover. For example, I use the plugin SimpylFold which defines folds for python as I want it and vimtex for latex files. However, I would not know if vim can combine this for a single latex file using pythontex.
I am not familiar with other editors and their solutions for this. A quick search revealed for Visual Studio Code that vscode supports out of the box adjusted syntax highlighting and commenting.
Did I miss something in vim itself supporting loading/unloading ftplugin/indent or do you occasionally change the filetype by yourself?
Today many tasks (e.g. autocompletion, linting, snippets, formatting) are provided by dedicated plugins: Which of the major plugins i.e. ycm, deoplete, ale, syntastic, tagbar, ultisnips, snipmate, autoformat and neoformat support this?