-2

Is there any difference between the following two commands:

autocmd FileType html,htmldjango inoremap <buffer> <leader>1 &nbsp;

And converted to an autocmd:

augroup filetype_html
    autocmd!
    autocmd FileType html,htmldjango inoremap <buffer> <leader>1 &nbsp;
augroup END

Is one preferable over the other, or are they two different ways of saying the same thing? If so, why should one be used over the other?

1
  • 3
    Before posting 12 questions in a row, please do some researches on this site to make sure you are not creating duplicates. If the built-in search is not enough remember that you can use site:vi.stackexchange.com in your favorite search engine to limit the results to our site.
    – statox
    Jun 12 '20 at 7:21
2

Always use augroup followed by autocmd!. Period.

The major problem is that executing

autocmd BufRead * echomsg 'foobar'

twice will result in printing foobar twice per each BufRead.

Not the answer you're looking for? Browse other questions tagged or ask your own question.