简体   繁体   中英

Correct Indentation of a buffer with js2-mode in Emacs

在Emacs中使用js2-mode编辑javascript文件时,有没有办法自动纠正整个缓冲区(或区域)的缩进?

CM-\\ runs indent-region . If you want to indent the entire buffer, you can do so with Cx h ( mark-whole-buffer ) followed by CM-\\ .

I use this regularly to clean up things

 (defun cleanup-buffer ()
   "Perform a bunch of operations on the whitespace content of a buffer."
   (interactive)
   (indent-buffer)
   (untabify-buffer)
   (delete-trailing-whitespace)
   (delete-trailing-blank-lines))

 (global-set-key (kbd "C-c n") 'cleanup-buffer)

UPDATE:
to be precise answer for your question. try Mx indent-buffer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM