I want to list all filetypes Vim recognizes from its runtimepath.

For example:


How can I do it?

up vote 17 down vote accepted

If you need those for a custom command that takes filetype arguments, you can just use :command -complete=filetype. Else, you can derive the list via the globpath() function yourself:

echo join(map(split(globpath(&rtp, 'ftplugin/*.vim'), '\n'), 'fnamemodify(v:val, ":t:r")'), "\n")

This gets all ftplugin scripts from the runtimepath, and then modifies the filespec via fnamemodify() to only list the root of the filename. split() converts into a List, and join() back to lines for :echoing.

  • Does this take files from ftplugin/after, too? – Profpatsch Oct 24 '13 at 7:47
  • 2
    You mean after/ftplugin, and yes, because those are contained in &rtp. – Ingo Karkat Oct 24 '13 at 8:23
  • This gives a syntax error on both bash and zsh. – mareoraft Jun 24 '15 at 13:59
  • 2
    @mareoraft: Try this inside Vim, not in the shell! – Ingo Karkat Jun 24 '15 at 20:19
  • @IngoKarkat zoinks! works great, thanks! – mareoraft Jun 25 '15 at 3:45

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.