Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format all files under a dir in emacs?

Tags:

emacs

In emacs, I format a file as: 1) C-x h (or M-x mark-whole-buffer) 2) C-M-\ (or M-x indent-region)

I need help show me how to format all files under a dir?

like image 476
lot Avatar asked Mar 31 '10 09:03

lot


Video Answer


1 Answers

Create a macro to do it. Open the directory in dired (C-x d), and then:

  1. Put point on the first file.
  2. Press F3 to start recording the macro.
  3. Hit RET to open the file.
  4. Format it with C-x h, C-M-\.
  5. Bury the buffer with M-x bury-buffer. You'll be back in the dired buffer.
  6. Go down one line.
  7. Hit F4 to stop recording the macro.

So now you have a macro that opens the file on the current line, formats it, drops back to dired, and puts point to the next line. Run it with F4 as many times as needed.

like image 103
legoscia Avatar answered Oct 11 '22 02:10

legoscia