我想列出 Vim 从其运行时路径识别的所有文件类型。
例如:
ada
arc
c
clojure
common-lisp
elisp
go
python
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
Ing*_*kat 19
如果您需要那些带有文件类型参数的自定义命令,您可以使用:command -complete=filetype. 否则,您可以globpath()自己通过函数导出列表:
echo join(map(split(globpath(&rtp, 'ftplugin/*.vim'), '\n'), 'fnamemodify(v:val, ":t:r")'), "\n")
Run Code Online (Sandbox Code Playgroud)
这会从运行时路径中获取所有 ftplugin 脚本,然后修改 filespec viafnamemodify()以仅列出文件名的根目录。split()转换为一个列表,并join()返回到:echoing 的行。