4

I am trying to add :autocmd BufWrite * make to modeline in vim, but it is not triggered. I see that the help says only set <options> can be used in modelines. Is there a way to achieve this effect, where I write a file to run make.

Bill Xia
  • 299
  • 2
  • 14
shoban
  • 650
  • 1
  • 9
  • 14

1 Answers1

3

Set your autocmd in your ~/.vimrc with a pattern that will match your file name. I would also suggest using augroup so it can be made to be re-sourced.

augroup my_project
  autocmd!
  autocmd BufWrite /project/*.c make
augroup END

For more help see:

:h :au
:h :aug
Peter Rincker
  • 43,539
  • 9
  • 74
  • 101