how would I figure this out?
I added delete-trailing-whitespace
to the before-save-hook
in my c-mode-common-hook
, but it loo
Yes create a .dir-locals.el
file in your project root directory with this contents:
((c-mode . ((before-save-hook . (lambda() (delete-trailing-whitespace)) )) ))
This will add this hook only to c-mode
buffers below this directory.
But if you only want a specific file and not a whole directory you should be able to add this to top of file using File Local Variables:
-*- eval: (setq before-save-hook (lambda() (delete-trailing-whitespace))); -*-
or bottom of file like this:
;;; Local Variables: ***
;;; eval: (setq before-save-hook (lambda() (delete-trailing-whitespace))) ***
;;; End: ***