0

Add customise filetype setting file do.vim inside ftdetect folder.
Edit gvim/8.2/share/vim/vim82/filetype.vim:
runtime! $HOME/.vim/ftdetect/*.vim
Open file, run verbose set ft?. From print, filetype is still default conf.
filetype=conf
Last set from ~/TOOLS/gvim/8.2/share/vim/vim82/filetype.vim line 2193

If comment out runtime! and add so $HOME/.vim/ftdetect/do.vim.
Open file, run verbose set ft?, it shows correct filetype setting.
filetype=tcl
Last set from ~/bin/vim/env/vim/ftdetect/do.vim line 6
Note: $HOME/.vim is soft link to ~/bin/vim/env/vim.

Not sure why runtime! is not working. enter image description here

2
  • Is the screenshot taken from $VIMRUNTIME/filetype.vim? Did you modify line 2182? It should read runtime! ftdetect/*.vim. The runtime-command already takes care of searching your local .vim directory (and all the other paths in 'runtimepath'). Oct 20 '21 at 9:00
  • Yes, you are right. If I revert the change and use default runtime! command, it's working. So problem is the path.
    – Fisher
    Oct 20 '21 at 9:09
1

Edit gvim/8.2/share/vim/vim82/filetype.vim

Messing with standard config files is discouraged unless one clearly understands what's he doing. (And even then the chances are one shouldn't do this, never ever).

runtime! $HOME/.vim/ftdetect/*.vim

This is wrong for a pretty simple reason: basically what :runtime! does, it iterates through all paths in :h 'runtimepath', prepends each one as a prefix to your path and then tries to :source the resulting file name/wildcard. Hence the right syntax is runtime! ftdetect/*.vim.

However, it's already in $VIMRUNTIME/filetype.vim which will be sourced upon :filetype on and so it needs not be touched AT ALL.

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.