Question

I usually have to deal with a lot of people sending me Windows files and I'm tired of having to convert them by hand, usually by doing:

 C-x RET f unix RET

Is there any way to add a global hook (for all modes) to automatically do this on saves?

Was it helpful?

Solution

(defun unix-newline () (set-buffer-file-coding-system 'undecided-unix))
(add-hook 'before-save-hook 'unix-newline)

I also like:

(add-hook 'before-save-hook 'delete-trailing-whitespace)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top