autocmd
An autocmd, short for auto-command, is a feature of Vim and Neovim that runs a specified command automatically when a defined event occurs, such as opening a file, entering a buffer, or writing a buffer. Autocommands let users tailor editor behavior without manual invocation.
Autocommands are defined with the syntax: autocmd {event} {pattern} {command}. Events include BufRead, BufNewFile, BufEnter, BufWritePost,
To organize and manage them, autocommands are typically placed inside augroups. Use augroup Name to start a
- autocmd BufReadPost *.md setlocal textwidth=80
- autocmd FileType python setlocal expandtab shiftwidth=4
- autocmd BufNewFile,BufReadPost *.log setlocal nospell
Viewing and learning more: :autocmd lists active autocommands, and :help autocmd opens detailed documentation. Good practice