I've read the Emacs documentation for align-regexp
but still have difficulty in understanding how it works. What I'm talking about is its prefixed form C-uM-xalign-regexp
, not the simple form M-xalign-regexp
. Here are my questions:
- Does the first parameter (the regex) have to match the whole line of string? What if the regex only matchs a part of the string?
- What to supply to the second parameter (Parenthesis group to modify (justify if negative))? As I understand here I need to supply a captured group number (count from 1), right? Does "justify if negative" means, if I want group 3 to right aligned, I'll supply
-3
as the input? - What does the third parameter "amount of spacing (or column if negative)" mean? I just totally don't understand what this parameter does.
I've collect some text examples to practice. If anyone can use below text as examples that will be very helpful.
From
class CreateStudents < ActiveRecord::Migration
def change
create_table :students, :comment => "学生信息表" do |t|
t.string :political_status, :comment => "政治面貌"
t.string :education_level, :comment => "培养层次"
t.string :enroll_method, :comment => "入学方式"
t.date :enrolled_at, :comment => "入学时间"
t.string :charge_type, :comment => "收费类别"
t.string :enrolled_year, :comment => "学籍年度"
t.string :enrolled_place, :comment => "生源所在地"
t.string :bank_card_number, :comment => "银行卡号"
t.string :bank_account_number, :comment => "银行账号"
t.boolean :is_active_duty, :default => false, :comment => "是否现役军人"
t.boolean :is_equivalent_degree, :default => false, :comment => "是否同等学历"
t.boolean :is_on_record, :default => true, :comment => "是否在籍"
t.boolean :is_at_school, :default => true, :comment => "是否在校"
t.timestamps
end
end
end
To
class CreateStudents < ActiveRecord::Migration
def change
create_table :students, :comment => "学生信息表" do |t|
t.string :political_status, :comment => "政治面貌"
t.string :education_level, :comment => "培养层次"
t.string :enroll_method, :comment => "入学方式"
t.date :enrolled_at, :comment => "入学时间"
t.string :charge_type, :comment => "收费类别"
t.string :enrolled_year, :comment => "学籍年度"
t.string :enrolled_place, :comment => "生源所在地"
t.string :bank_card_number, :comment => "银行卡号"
t.string :bank_account_number, :comment => "银行账号"
t.boolean :is_active_duty, :default => false, :comment => "是否现役军人"
t.boolean :is_equivalent_degree, :default => false, :comment => "是否同等学历"
t.boolean :is_on_record, :default => true, :comment => "是否在籍"
t.boolean :is_at_school, :default => true, :comment => "是否在校"
t.timestamps
end
end
end
From
my @primes = (
1,2,3,5,7,
11,13,17,19,23,
29,31,37,41,43,
);
To
my @primes = (
1, 2, 3, 5, 7,
11, 13, 17, 19, 23,
29, 31, 37, 41, 43,
);