-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?

David542
  • 2,445
  • 14
  • 50
  • 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 07:21

1 Answers1

3

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.

Matt
  • 20,685
  • 1
  • 11
  • 24