简体   繁体   中英

What elisp or macro magic can make this text transformation?

I have a set of SQL statements formatted like so:

INSERT INTO reports.workload (workload_id,event_time,event_type_id,agent_id) VALUES 
                             (-42000,'2010-02-23 07:30:38.941436',1,NULL);

Right now, the VALUES tuple is aligned at the start with the column name tuple. However, what I want is to have the tuple's elements aligned as well, like so:

INSERT INTO reports.workload (workload_id,event_time,                  event_type_id,agent_id) VALUES 
                             (-42000,     '2010-02-23 07:30:38.941436',1            ,NULL);

My elisp-fu and regexp-fu are moderate, but not sufficient to this task. How can I do this?

Select the region you'd like to align, and type Cu Cx \\ (that is a shortcut for align-regexp ). Choose \\(,\\) as regex pattern and repeat it throughout line.

For more on text align, see chapter AlignCommands in EmacsWiki.

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