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?
Asked
Active
Viewed 1,650 times
1

Eugene Yarmash
- 142,882
- 41
- 325
- 378
-
1https://vimhelp.org/autocmd.txt.html#autocmd-list – phd Mar 16 '20 at 18:22
-
I guess it's safe to say using a `vimrc_` prefix is almost sure not to generate any conflicts. – filbranden Mar 16 '20 at 19:24
-
1@phd That command actually lists auto-commands, not the autocmd groups... Running `autocmd` by itself lists them, but that doesn't appear to be documented. Added an answer. – filbranden Mar 16 '20 at 19:38
1 Answers
7
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'))

filbranden
- 8,522
- 2
- 16
- 32