New answers tagged

1

It turns out, there is a subtle interaction between FileType events and the actual ftplugin mechanism. When the filetype is changed, all matching FileType events are run. As near as I can tell, this is one of the first things to be done. So the current "state" would include both the buffer-local mapping and the b:undo_ftplugin necessary to undo it. This ...


1

Explaining the steps you can use to troubleshoot such issues. First, you can use a command such as :au BufRead *.mm to inspect which autocmds exist for that particular extension. You can use that to double check that your configuration actually took effect. (Which it did in your case.) Second, you can use command :verbose set ft? to inspect the filetype ...


2

I did find an alternative approach, which is to put my autocmds instead in ~/.vim/filetype.vim. They seem to be evaluated first over autocmds in plugins.


0

You can use mysyntaxfile hook. E.g. " in vimrc let g:mysyntaxfile = '~/vimfiles/after/syntax/base.vim' syntax on ... " in base.vim autocmd Syntax javascript,c call DoWhatever(expand('<amatch>')) Note that you don't need augroup and stuff, as synload.vim manages syntax files by its own.


1

If in specific you would like to avoid the mklink on Windows or symlinks on Linux/Unix/Mac, you can use small files for the specific languages that simply load base.vim. The technique is recommended in :help :syn-files: When a language is a superset of another language, it may include the other one, for example, the cpp.vim file could include the c.vim ...


3

The reason for this is that both *.adoc and *.fr.adoc match for foo.fr.adoc, so both autocmds are run. The documentation for autocmd patterns is at :help file-pattern; looking at it, doing a robust "match *.adoc but not fr.adoc" is a bit tricky (though not impossible). Personally, I would opt for just an if: autocmd BufNewFile *.adoc \ if ...


1

Within cpp.vim put: source <sfile>:h/c.vim <sfile> expands to the currently sourced file, and :h means the head of it.


Top 50 recent answers are included