如何使用align
emacs命令对齐结构如下的文件?
key.name1 "his value 1"; # the comment
key.name2 "his other value";
otherkey.id 10; # comment
key.without.other ; # comment
key2.without.other true; # comment
我在emacs 25下使用conf-mode
。
列编码如下:
#
“开头。结果应为
key.name1 "his value 1"; # the comment
key.name2 "his other value";
otherkey.id 10; # comment
key.without.other ; # comment
key2.without.other true; # comment
答案 0 :(得分:1)
最好能描述一下你希望如何看待这种情况。
通过选择这些行并使用前缀参数运行align-regexp
,我可以使用以下正则表达式来查找所有这些字段,方法是查找多个连续的空格。这可能不是最好的解决方案,但它适用于此示例数据。
铜 的Mx align-regexp
RET \(\s-\s-+\)
RET RET < / KBD> RET ý
结果:
key.name1 "his value 1" # the comment
key.name2 "his other value" # another comment
otherkey.id 10 # comment