Search code examples
regexemacseval

Emacs align-regexp


I am new to Emacs. I want to use align-regexp so that I can align my text based on square bracket [. I am able to do this from GUI like this M-x align-regexp: \[ I want to create an alias using emacs --eval since I use this frequently. I did some thing like this

emacs <filename> --eval "(progn (mark-whole-buffer) (align-regexp \[))"

This selects whole buffer. But nothing after that. Please help me to do it.


Solution

  • emacs -batch f1 --eval '(align-regexp (point-min) (point-max) "\\(\\s-*\\)\\[" 1 1 nil)' -f save-buffer
    

    where f1 is the file name.