How to list autocmd groups in Vim?

2k Views Asked by At

In my .vimrc I want to define several autocmd groups. Also, I want to avoid conflicts with any pre-existing groups. How can I list currently defined groups in Vim?

1

There are 1 best solutions below

0
filbranden On BEST ANSWER

This actually doesn't appear to be documented in Vim's help (only mentions the commands to select or delete a group), but at least on my Vim 8.2.0318, the command :augroup by itself lists all the defined autocmd groups.

I get this on pretty much stock Vim setup:

:augroup
filetypedetect  syntaxset  filetypeplugin  filetypeindent  vimStartup  gzip  matchparen  FileExplorer  Network  tar  Vimball  

The :autocmd command, which lists all auto-commands will end up listing groups as well, but it's of course more convenient to get them directly from :augroup.

If you want to get that into a Vim variable, use the execute() function for it:

let groups = split(execute('augroup'))