currently I'm working a lot with json files. They tend to be a little bigger.
I'm a little fed up with always marking the whole file and then typing M-x json-reformat-region
.
Is there a way to do this directly on opening the file?
Regards
I use this hook to achieve an effect like that:
;; pretty print json files when they're opened
(add-to-list 'auto-mode-alist
'("\\.json\\'" . (lambda ()
(javascript-mode)
(json-pretty-print (point-min) (point-max))
(goto-char (point-min))
(set-buffer-modified-p nil))))
json-pretty-print
by json-reformat-region
json-mode
and json-snatcher
installed. I open the file and nothings happens...
json-mode
that pretty prints the buffer.
json-reformat-region
belongs. So here is my adapted version. ;; pretty print json files when they're opened (add-to-list 'auto-mode-alist '("\\.json\\'" . (lambda () (json-mode) (json-reformat-region (point-min) (point-max)) (goto-char (point-min)) (set-buffer-modified-p nil))))