2026-02-24 10:39AM
在下面的代码中,我想要实现快速换行
map[string]interface {}{map[string]interface {}{"car_total":8.934800000000001, "coach_total":172.62400000000002, "emission_all_134a":192.75364000000002, "emission_all_407c":5.97516, "truck_total":11.194840000000001, "year":2009}, map[string]interface {}{"car_total":17.6016, "coach_total":342.048, "emission_all_134a":381.79478, "emission_all_407c":11.81982, "truck_total":22.145180000000003, "year":2010}, map[string]interface {}{"car_total":26.2684, "coach_total":511.472, "emission_all_134a":570.83592, "emission_all_407c":17.664479999999998, "truck_total":33.09552, "year":2011}, map[string]interface {}{"car_total":34.9352, "coach_total":680.896, "emission_all_134a":759.87706, "emission_all_407c":23.509140000000002, "truck_total":44.045860000000005, "year":2012}, map[string]interface {}{"car_total":43.602, "coach_total":850.3199999999999, "emission_all_134a":948.9182, "emission_all_407c":29.353799999999996, "truck_total":54.9962, "year":2013}, map[string]interface {}{"car_total":52.2688, "coach_total":1019.744, "emission_all_134a":1137.95934, "emission_all_407c":35.19846, "truck_total":65.94654, "year":2014}, map[string]interface {}{"car_total":60.9356, "coach_total":1189.1680000000001, "emission_all_134a":1327.0004800000002, "emission_all_407c":41.043119999999995, "truck_total":76.89688, "year":2015},
实现为下面这样
map[string]interface {}{map[string]interface {}{"car_total":8.934800000000001, "coach_total":172.62400000000002, "emission_all_134a":192.75364000000002, "emission_all_407c":5.97516, "truck_total":11.194840000000001, "year":2009},
map[string]interface {}{"car_total":17.6016, "coach_total":342.048, "emission_all_134a":381.79478, "emission_all_407c":11.81982, "truck_total":22.145180000000003, "year":2010},
map[string]interface {}{"car_total":26.2684, "coach_total":511.472, "emission_all_134a":570.83592, "emission_all_407c":17.664479999999998, "truck_total":33.09552, "year":2011},
map[string]interface {}{"car_total":34.9352, "coach_total":680.896, "emission_all_134a":759.87706, "emission_all_407c":23.509140000000002, "truck_total":44.045860000000005, "year":2012},
map[string]interface {}{"car_total":43.602, "coach_total":850.3199999999999, "emission_all_134a":948.9182, "emission_all_407c":29.353799999999996, "truck_total":54.9962, "year":2013},
map[string]interface {}{"car_total":52.2688, "coach_total":1019.744, "emission_all_134a":1137.95934, "emission_all_407c":35.19846, "truck_total":65.94654, "year":2014},
map[string]interface {}{"car_total":60.9356, "coach_total":1189.1680000000001, "emission_all_134a":1327.0004800000002, "emission_all_407c":41.043119999999995, "truck_total":76.89688, "year":2015},
在 vim 编辑器里面
1. 可以使用这个命令来快速实现
:%s/},/},\r/g
2. 我如果想要在 map 前面进行换行,可以使用下面的这个命令,来快速实现:
:%s/map/\r&/g
批量换行的核心是调整 \r 位置 ——\r& 前换行,&\r (或者\r)后换行
登录
请登录后再发表评论。
评论列表:
目前还没有人发表评论