Add Vim exercises, cheatsheet, and project polish
Add code golf challenges for Vim practice, a weekly review template, and extend the cheatsheet with high-frequency commands. Fix the calculator `multiply` implementation and correct a logger import path.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// ============================================================
|
||||
// Code Golf 场景 1:函数签名修改
|
||||
// ============================================================
|
||||
//
|
||||
// 目标:用最少的 Vim 按键把下面的代码改成目标代码。
|
||||
// 记录你的按键数!
|
||||
//
|
||||
// 💡 提示:c w 改单词、f ( 跳到括号、c i ( 修改参数、A 行尾追加
|
||||
// ============================================================
|
||||
|
||||
function greet(name: string): string {
|
||||
return "Hello, " + name;
|
||||
}
|
||||
|
||||
// === 目标代码(用最少按键达到) ===
|
||||
//
|
||||
// function sayHelloTo(firstName: string, lastName: string): string {
|
||||
// return `Hello, ${firstName} ${lastName}!`;
|
||||
// }
|
||||
//
|
||||
// ============================================================
|
||||
// 我的最佳成绩:
|
||||
// 日期: ________ 按键数: ________
|
||||
// 操作日志: ________________________________
|
||||
// ============================================================
|
||||
@@ -0,0 +1,30 @@
|
||||
// ============================================================
|
||||
// Code Golf 场景 2:对象属性重排
|
||||
// ============================================================
|
||||
//
|
||||
// 目标:把 id 属性移到最后,用最少按键。
|
||||
//
|
||||
// 💡 提示:d d 删除行、p 粘贴、V 行选择、:m 移动
|
||||
// ============================================================
|
||||
|
||||
const user = {
|
||||
id: 1,
|
||||
name: "Alice",
|
||||
email: "alice@example.com",
|
||||
age: 30,
|
||||
};
|
||||
|
||||
// === 目标代码 ===
|
||||
//
|
||||
// const user = {
|
||||
// name: "Alice",
|
||||
// email: "alice@example.com",
|
||||
// age: 30,
|
||||
// id: 1,
|
||||
// };
|
||||
//
|
||||
// ============================================================
|
||||
// 我的最佳成绩:
|
||||
// 日期: ________ 按键数: ________
|
||||
// 操作日志: ________________________________
|
||||
// ============================================================
|
||||
@@ -0,0 +1,43 @@
|
||||
// ============================================================
|
||||
// Code Golf 场景 3:批量加注释
|
||||
// ============================================================
|
||||
//
|
||||
// 目标:给三个函数上面各加一行注释 "// Arithmetic operation: <函数名>"
|
||||
//
|
||||
// 💡 提示:用宏!q a 开始录制 → 在第一行编辑 → j → q 停止 → @a 回放
|
||||
// ============================================================
|
||||
|
||||
function add(a: number, b: number): number {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
function subtract(a: number, b: number): number {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
function multiply(a: number, b: number): number {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
// === 目标代码 ===
|
||||
//
|
||||
// // Arithmetic operation: add
|
||||
// function add(a: number, b: number): number {
|
||||
// return a + b;
|
||||
// }
|
||||
//
|
||||
// // Arithmetic operation: subtract
|
||||
// function subtract(a: number, b: number): number {
|
||||
// return a - b;
|
||||
// }
|
||||
//
|
||||
// // Arithmetic operation: multiply
|
||||
// function multiply(a: number, b: number): number {
|
||||
// return a * b;
|
||||
// }
|
||||
//
|
||||
// ============================================================
|
||||
// 我的最佳成绩:
|
||||
// 日期: ________ 按键数: ________
|
||||
// 操作日志: ________________________________
|
||||
// ============================================================
|
||||
@@ -0,0 +1,28 @@
|
||||
// ============================================================
|
||||
// Code Golf 场景 4:数组转对象
|
||||
// ============================================================
|
||||
//
|
||||
// 目标:在 keys/values 上方创建 person 对象,用最少按键。
|
||||
//
|
||||
// 💡 提示:O 在上方插入、手动拼对象、或 y i w + p 配合编辑
|
||||
// ============================================================
|
||||
|
||||
const keys = ["name", "age", "email"];
|
||||
const values = ["Alice", 30, "alice@example.com"];
|
||||
|
||||
// === 目标代码 ===
|
||||
//
|
||||
// const person = {
|
||||
// name: "Alice",
|
||||
// age: 30,
|
||||
// email: "alice@example.com",
|
||||
// };
|
||||
//
|
||||
// const keys = ["name", "age", "email"];
|
||||
// const values = ["Alice", 30, "alice@example.com"];
|
||||
//
|
||||
// ============================================================
|
||||
// 我的最佳成绩:
|
||||
// 日期: ________ 按键数: ________
|
||||
// 操作日志: ________________________________
|
||||
// ============================================================
|
||||
@@ -0,0 +1,41 @@
|
||||
// ============================================================
|
||||
// Code Golf 场景 5:删除所有 console.log
|
||||
// ============================================================
|
||||
//
|
||||
// 目标:删除函数体内所有 console.log 语句,用最少按键。
|
||||
//
|
||||
// 💡 提示:g l 选中所有 console.log → d 删除它们!
|
||||
// 或者::g/console\.log/d 全局删除匹配行
|
||||
// ============================================================
|
||||
|
||||
function process(): void {
|
||||
console.log("Starting...");
|
||||
const a = doThing();
|
||||
console.log("After thing:", a);
|
||||
const b = doOtherThing();
|
||||
console.log("After other:", b);
|
||||
console.log("Done!");
|
||||
return b;
|
||||
}
|
||||
|
||||
function doThing(): number {
|
||||
return 42;
|
||||
}
|
||||
|
||||
function doOtherThing(): number {
|
||||
return 84;
|
||||
}
|
||||
|
||||
// === 目标代码 ===
|
||||
//
|
||||
// function process(): void {
|
||||
// const a = doThing();
|
||||
// const b = doOtherThing();
|
||||
// return b;
|
||||
// }
|
||||
//
|
||||
// ============================================================
|
||||
// 我的最佳成绩:
|
||||
// 日期: ________ 按键数: ________
|
||||
// 操作日志: ________________________________
|
||||
// ============================================================
|
||||
@@ -6,6 +6,7 @@
|
||||
- 只能用 Vim 快捷键,不能使用鼠标
|
||||
- 记录按键数(不包括撤销的 `u`)
|
||||
- 每次完成后在表格填入你的最佳成绩
|
||||
- 📁 每个场景都有对应的 `.ts` 练习文件在 `challenges/` 目录下,直接打开即可练习
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -56,3 +56,38 @@
|
||||
| 5 | / 搜索 + n | 12 | 多光标 gl | 19 | Speed Drill |
|
||||
| 6 | 文本对象 i/a | 13 | Surround ys/ds/cs | 20 | 综合挑战 |
|
||||
| 7 | 操作符 d/c/y | 14 | 可视模式 V/v | 21 | 终极大挑战 |
|
||||
|
||||
---
|
||||
|
||||
## 🗓 周末回顾模板
|
||||
|
||||
> 每周六/日花 15 分钟回顾,比每天练习更重要。
|
||||
|
||||
```
|
||||
📅 第____周回顾 (____年____月____日)
|
||||
|
||||
🏆 本周突破
|
||||
- ________________________________
|
||||
- ________________________________
|
||||
- ________________________________
|
||||
|
||||
⚠️ 薄弱环节
|
||||
- ________________________________
|
||||
- ________________________________
|
||||
|
||||
🎯 下周目标
|
||||
- ________________________________
|
||||
- ________________________________
|
||||
|
||||
🧪 自测挑战(计时!)
|
||||
□ Speed Drill 挑战 3: 文本对象连击 → 用时: ____
|
||||
□ Speed Drill 挑战 4: 重命名风暴 → 用时: ____
|
||||
□ Code Golf 场景 5: 删除 console.log → 按键数: ____
|
||||
|
||||
📊 本周 stats
|
||||
练习天数: ____/7
|
||||
Speed Drill 新纪录: ____
|
||||
Code Golf 新纪录: ____
|
||||
|
||||
💬 一句话心得: ________________________________
|
||||
```
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## 挑战 1:hjkl 盲打
|
||||
|
||||
**目标**:在 `01-basics/practice.ts` 中,用 `j/k` 从第 1 行移动到第 50 行再回到第 1 行。
|
||||
**目标**:在 `01-basics/practice.ts` 中,用 `j/k` 从第 1 行移动到最后一行再回到第 1 行。
|
||||
|
||||
| 日期 | 时间 | 出错次数 | 备注 |
|
||||
|------|------|----------|------|
|
||||
|
||||
Reference in New Issue
Block a user