FormatCodes
首页/Zig 工具/Zig 格式化

Zig 格式化工具

在线格式化和校验 Zig 代码,基于官方 zig fmt 的 WebAssembly 版本,直接在浏览器中完成处理。

浏览器本地处理
无需登录
基于官方 zig fmt
语言
Zigmain.zig
zig fmt 风格固定:4 空格缩进 · 无可配置选项快速格式化
输入可编辑
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
输出Zig 有效49 行 · 969 B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const std = @import("std");
const Allocator = std.mem.Allocator;
const Node = struct {
value: i32,
next: ?*Node,
pub fn init(value: i32) Node {
return .{ .value = value, .next = null };
}
};
const LinkedList = struct {
head: ?*Node = null,
allocator: Allocator,
pub fn init(allocator: Allocator) LinkedList {
return .{ .allocator = allocator };
}
pub fn push(self: *LinkedList, value: i32) !void {
const node = try self.allocator.create(Node);
node.* = Node.init(value);
node.next = self.head;
self.head = node;
}
pub fn sum(self: *const LinkedList) i32 {
var total: i32 = 0;
var current = self.head;
while (current) |node| {
total += node.value;
current = node.next;
}
return total;
}
};
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
var list = LinkedList.init(allocator);
try list.push(1);
try list.push(2);
try list.push(3);
std.debug.print("Sum: {d}\n", .{list.sum()});
}
UTF-8 · 4 空格缩进 · zig fmt本地处理 · 就绪
工具说明Zig
简介
把缩进混乱或风格不统一的 Zig 代码重新整理成标准格式,底层使用 zig fmt 的 WebAssembly 编译版本,格式化结果与本地执行 zig fmt 命令完全一致。所有处理都在浏览器本地完成,代码不会离开你的设备。
场景
格式化粘贴自文档或 AI 生成的 Zig 代码整理缩进混乱的旧代码校验 Zig 语法是否正确统一团队 Zig 代码风格
使用步骤
123
粘贴或上传自动格式化获取结果

相关工具

相关指南

常见问题

搜索工具

搜索 55+ 个格式化、转换、压缩、对比与生成工具