// ============================================================ // 第一阶段练习文件 — 基础移动和编辑 // ============================================================ // // 任务:用 hjkl 移动光标到此文件的每一行,然后按 dd 删除它。 // 删除后,用 u 撤销,继续下一行。 // // 练习步骤: // 1. 按 j 向下,按 k 向上 // 2. 按 dd 删除一行,按 u 撤销 // 3. 按 o 在下方新增一行,输入 "I added this line!" // 4. 按 A 跳到行尾,输入 " - done" // 5. 按 I 跳到行首,输入 "// " // ============================================================ const hello = "Hello, Zed Vim!"; const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; function greet(name: string): string { return `Hello, ${name}! Welcome to Vim mode.`; } function sumArray(arr: number[]): number { let total = 0; for (let i = 0; i < arr.length; i++) { total += arr[i]; } return total; } class User { name: string; email: string; isActive: boolean; constructor(name: string, email: string) { this.name = name; this.email = email; this.isActive = true; } deactivate(): void { this.isActive = false; } getDisplayName(): string { return `${this.name} <${this.email}>`; } } const user = new User("Alice", "alice@example.com"); console.log(greet(user.name)); console.log("Sum:", sumArray(numbers)); console.log("Active:", user.isActive);