Print All Syntax Highlight File Types

3 views
Skip to first unread message

Stratis Aftousmis

unread,
Dec 21, 2009, 11:13:42 PM12/21/09
to v...@vim.org
Hello! : )

Is there a command to print all syntax highlight file types in vim?

I am writing a script that sends a command to vim and returns the
different highlight file types vim supports.

Thanks for any help.

Stratis

Christian Brabandt

unread,
Dec 22, 2009, 1:43:27 AM12/22/09
to vim...@googlegroups.com
On Tue, December 22, 2009 5:13 am, Stratis Aftousmis wrote:
> Hello! : )
>
> Is there a command to print all syntax highlight file types in vim?
>
> I am writing a script that sends a command to vim and returns the
> different highlight file types vim supports.

echo globpath(&rtp, "**/syntax/*.vim")

regards,
Christian

Stratis Aftousmis

unread,
Dec 22, 2009, 2:00:10 AM12/22/09
to vim...@googlegroups.com
Eww that's pretty messy.

I guess I would have to parse the strings for file name...


--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

Christian Brabandt

unread,
Dec 22, 2009, 2:42:07 AM12/22/09
to vim...@googlegroups.com
[quoting repaired]
(Please don't top post).

On Tue, December 22, 2009 8:00 am, Stratis Aftousmis wrote:
> On Tue, Dec 22, 2009 at 1:43 AM, Christian Brabandt

>> echo globpath(&rtp, "**/syntax/*.vim")


> Eww that's pretty messy.
>
> I guess I would have to parse the strings for file name...

What would you like to do? This was just a starter. Here is a snippet
that lets you chose your filetype, based on all available syntax items
using a completion:

,----
| if !exists("s:ftdict")
| let s:ftdict={}
| let s:ftlist=map(split(globpath(&rtp, "**/syntax/*.vim"), "\n"),
'fnamemodify(v:val, ":t:r")')
| for val in s:ftlist
| let s:ftdict[val]=1
| endfor
| endif
|
| fu! <SID>FileTypeComplete(ArgLead,CmdLine,CursorPos)
| let l=filter(keys(s:ftdict), 'v:val =~ "^".a:ArgLead')
| return sort(l)
| endfu
|
| :com! -nargs=1 -complete=customlist,<SID>FileTypeComplete Filetype :set
ft=<args>
`----

regards,
Christian

Tony Mechelynck

unread,
Feb 16, 2010, 4:42:32 AM2/16/10
to vim...@googlegroups.com, Christian Brabandt

There are also the menus:
- After using "Syntax => Show filetypes in menu", you'll get of the
filetypes at top of the Syntax menu.
- You can get these menus even in Console mode (if your Vim is compiled
with +menu), as follows:

---8<------8<------8<---
" set 'wildmenu' option, to get completion-by-menu
" (on the status line when hitting Tab)
if has('wildmenu')
set wildmenu wildmode=longest:full,full
else
set wildmode=longest,list:longest,full
endif
set wildcharm=<C-T> " or any key not needed in Command-line mode
if has('menu')
" in gvim, :filetype on loads the menus
" but in Console mode, it must be done separately
if !has('gui_running')
runtime menu.vim
endif
" override Ctrl-Z (minimize) by a text-mode menu
map <C-Z> :emenu <C-T>
imap <C-Z> <C-O>:emenu <C-T>
endif
--->8------>8------>8---

(Use of <> mode in mappings assumes 'nocompatible' mode.)


Best regards,
Tony.
--
We're knights of the round table
We dance whene'er we're able
We do routines and chorus scenes
With footwork impeccable.
We dine well here in Camelot
We eat ham and jam and spam a lot.
"Monty Python and the Holy Grail" PYTHON (MONTY)
PICTURES LTD

Reply all
Reply to author
Forward
0 new messages