5

When I'm editing my vimrc, if I gg=G vim autoindents nicely except where augroup is involved

I end up with

augroup movingBackup au! au BufWritePost * call WriteBackupFile(expand("%:t"), expand("%:p:h")) augroup end augroup dotFile au! au BufWritePost *.dot :silent !start cmd /c "dot -T png %:t > %:r.png" augroup end nmap j gj nmap k gk 

when I really want

augroup movingBackup au! au BufWritePost * call WriteBackupFile(expand("%:t"), expand("%:p:h")) augroup end augroup dotFile au! au BufWritePost *.dot :silent !start cmd /c "dot -T png %:t > %:r.png" augroup end nmap j gj nmap k gk 
2
  • 3
    can you try using END instead of end for the closing part of augroup ? It should act the same, but with the lower-case version it would not work whereas with the uppercase it works Commented Apr 19, 2016 at 15:19
  • 2
    @Nobe4 that does it! (do you want to 'answer' it so I can mark you and the solution?) Commented Apr 19, 2016 at 15:20

1 Answer 1

8

You should use END instead of end for the closing augroup statement.

Apparently it's a bug (cf Carpetsmoker's comment), it should behave the same but it does not. From the documentation (:h :aug):

 *:aug* *:augroup* :aug[roup] {name} Define the autocmd group name for the following ":autocmd" commands. The name "end" or "END" selects the default group. To avoid confusion, the name should be different from existing {event} names, as this most likely will not do what you intended. 

Edit: I opened an issue regarding this question on the vim's github repo, and got an answer:

Although both "end" and "END" work, using "END" is recommended.

I'll change the indent script to also accept "end" (negatively) for incrementing the indent.

4
  • 5
    This is because the indent/vim.vim file does: elseif prev_text =~ '^\s*aug\%[roup]' && prev_text !~ '^\s*aug\%[roup]\s*!\=\s\+END'. This is a bug; the check should be case-insensitive. Commented Apr 19, 2016 at 16:07
  • 2
    Do you know if it's already acknowledged by the vim-team as a bug ? Commented Apr 19, 2016 at 16:07
  • 2
    No, that's just my own conclusion ;-) Commented Apr 19, 2016 at 16:10
  • 2
    haha, it's strange that for the indent only the regex is messed up, because for the syntax file, they use [eE][nN][dD] each time... I'll open an issue on the github repo. Commented Apr 19, 2016 at 16:15

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.