diff --git a/config/categories.yaml b/config/categories.yaml index 9c02f60..0825ae6 100644 --- a/config/categories.yaml +++ b/config/categories.yaml @@ -34,3 +34,8 @@ icon: πŸ”€ iconName: badge-check order: 7 +- id: vim + title: Vim & Modal Editing + icon: ⌨️ + iconName: keyboard + order: 8 diff --git a/tips/quick-task-spawn-shortcut.mdx b/tips/quick-task-spawn-shortcut.mdx new file mode 100644 index 0000000..469ad6a --- /dev/null +++ b/tips/quick-task-spawn-shortcut.mdx @@ -0,0 +1,132 @@ +--- +title: Launch Tasks Instantly with Alt-Shift-R +subtitle: One keystroke to open and execute your custom tasks +category: productivity +difficulty: beginner +tags: + - tasks + - shortcuts + - workflow + - productivity +mediaType: video +mediaUrl: 'https://cat.zed.tips/2026-01-29/quick-task-spawn-for-zed.mp4' +publishedAt: '2026-01-29' +updatedAt: '2026-01-29' +author: godruoyi +authorUrl: 'https://github.com/godruoyi' +--- + +Running custom tasks is one of Zed's most powerful features. With **Alt-Shift-R**, you can instantly open the task picker and execute any of your configured tasks with a single keystroke. + +## Why This Shortcut Matters + +**Speed**: Skip the command palette - go directly to task execution. + +**Workflow efficiency**: Build β†’ Test β†’ Deploy workflows become muscle memory. + +**Context awareness**: Zed shows tasks relevant to your current project. + +**Repeatability**: Execute the same task repeatedly during development. + +## Setup + +Add this to your `keymap.json`: + +```json +{ + "context": "Workspace", + "bindings": { + "alt-shift-r": ["task::Spawn", {}] + } +} +``` + +## What Are Tasks? + +Tasks in Zed are custom commands you define in `.zed/tasks.json`. They can be: +- Build commands (`npm run build`, `cargo build`) +- Test runners (`npm test`, `pytest`) +- Linters and formatters (`eslint .`, `cargo fmt`) +- Custom scripts specific to your project +- Multi-step workflows + +## Example Tasks Configuration + +Create `.zed/tasks.json` in your project: + +```json +[ + { + "label": "Run Tests", + "command": "npm test", + "tags": ["test"] + }, + { + "label": "Build Production", + "command": "npm run build", + "tags": ["build"] + }, + { + "label": "Lint & Format", + "command": "npm run lint && npm run format", + "tags": ["lint"] + }, + { + "label": "Start Dev Server", + "command": "npm run dev", + "tags": ["dev"] + } +] +``` + +## Workflow Example + +``` +1. Writing code in editor... +2. Press Alt-Shift-R +3. Task picker appears +4. Type "test" β†’ selects "Run Tests" +5. Press Enter +6. Tests run in integrated terminal +7. Continue coding +8. Press Alt-Shift-R β†’ "build" β†’ Enter +9. Production build completes +``` + +## Advanced Usage + +**Task with arguments**: Some tasks can accept dynamic input. + +**Task variables**: Use `$ZED_FILE`, `$ZED_DIRNAME`, etc. in your commands. + +**Task tags**: Filter tasks by tags for quick access. + +**Task history**: Recently used tasks appear at the top. + +## Pro Tips + +- Create task templates for common workflows (test β†’ build β†’ deploy) +- Use descriptive labels - they're searchable in the picker +- Combine with `space tab` to quickly switch back to your last buffer after task execution +- Tasks run in a persistent terminal, so you can see output history +- Group related tasks with tags for easier filtering + +## Why Alt-Shift-R? + +**R** = Run/Runner - mnemonic for executing tasks + +**Alt-Shift** = Modifier combination easy to hit with one hand + +**Non-conflicting**: Doesn't interfere with common Vim or editor shortcuts + +**Debugger alternative**: Some users also map this to `debugger::Start` for a unified "run" experience + +## Integration with Development Workflow + +This shortcut shines when combined with: +- Hot reload workflows (start dev server, make changes, auto-refresh) +- TDD cycles (write test, run test, write code, run test) +- Pre-commit checks (lint, format, test before committing) +- CI/CD simulation (run the same commands locally that run in CI) + +Once you configure your project's tasks and memorize Alt-Shift-R, running builds, tests, and scripts becomes effortless! diff --git a/tips/vim-power-user-workflow.mdx b/tips/vim-power-user-workflow.mdx new file mode 100644 index 0000000..652175a --- /dev/null +++ b/tips/vim-power-user-workflow.mdx @@ -0,0 +1,243 @@ +--- +title: Build a Complete Vim Power User Workflow in Zed +subtitle: >- + Master keyboard-driven editing with leader keys, motions, and efficient + navigation +category: vim +difficulty: intermediate +tags: + - vim + - workflow + - keybindings + - productivity + - navigation + - leader-key +publishedAt: '2026-01-29' +updatedAt: '2026-01-29' +author: godruoyi +authorUrl: 'https://github.com/godruoyi' +--- + +Transform Zed into a Vim power user's dream with this comprehensive workflow setup. This guide covers everything from escaping insert mode to building a complete leader key system. + +## πŸš€ Quick Escape from Insert Mode + +The first optimization every Vim user makes: map `jj` or `jk` to escape insert mode. + +```json +{ + "context": "Editor && vim_mode == insert && !menu", + "bindings": { + "j j": "vim::NormalBefore", + "j k": "vim::NormalBefore" + } +} +``` + +**Why it matters**: Keep fingers on home row instead of reaching for ESC. Both `jj` and `jk` work - choose based on preference. + +## πŸ—ΊοΈ Space as Leader Key System + +Build a discoverable, organized keybinding system with Space as your leader. Group commands by category for easy memorization. + +```json +{ + "context": "Editor && (vim_mode == normal || vim_mode == visual) && !VimWaiting && !menu", + "bindings": { + // Git Operations (space g) + "space g h d": "editor::ToggleSelectedDiffHunks", + "space g s": "git_panel::ToggleFocus", + "space g b": "git::Branch", + + // File & Project (space e/f) + "space e": "project_panel::ToggleFocus", + "space f p": "projects::OpenRecent", + + // Search & Symbols (space s) + "space s w": "pane::DeploySearch", + "space s s": "outline::Toggle", + "space s S": "project_symbols::Toggle", + + // Buffer Management (space b) + "space b b": "pane::ActivateLastItem", + "space b a": "pane::CloseAllItems", + "space tab": "pane::ActivateLastItem", + "space q": "pane::CloseActiveItem", + + // AI & Diagnostics (space a/x) + "space a": "agent::ToggleFocus", + "space x x": "diagnostics::Deploy", + + // UI Toggles (space t/c/z) + "space t i": "editor::ToggleInlayHints", + "space c z": "workspace::ToggleCenteredLayout", + "space z z": "workspace::ToggleZoom" + } +} +``` + +**Organization principles**: +- Two-letter prefixes for categories (g=git, s=search, b=buffers) +- Mnemonic choices make commands memorable +- Repeating letters for toggles (`space z z` for zoom) + +## 🎯 Vim Sneak for Precise Navigation + +Jump to any visible text with two-character searches - faster than `/` and more accurate than `f/t`. + +```json +{ + "context": "vim_mode == normal || vim_mode == visual", + "bindings": { + "s": "vim::PushSneak", + "S": "vim::PushSneakBackward" + } +} +``` + +**Usage**: Type `s` followed by two characters to jump forward. Works with operators too: `d s fu` deletes from cursor to "fu". + +## β¬…οΈβž‘οΈ Ergonomic History Navigation + +Replace awkward bracket navigation with intuitive Backspace/Enter keys. + +```json +{ + "context": "Editor && (vim_mode == normal || vim_mode == visual) && !VimWaiting && !menu", + "bindings": { + "backspace": "pane::GoBack", + "enter": "pane::GoForward", + "shift-backspace": "pane::GoToOlderTag", + "shift-enter": "pane::GoToNewerTag" + } +} +``` + +**Two-tier navigation**: +- **Backspace/Enter**: Regular history (all cursor movements) +- **Shift-Backspace/Enter**: Tag stack (only "Go to Definition" jumps) + +## πŸ“‘ Browser-Style Buffer Switching + +Navigate between open files with `H` and `L` - like browser tabs but on the home row. + +```json +{ + "context": "Editor && (vim_mode == normal || vim_mode == visual) && !VimWaiting && !menu", + "bindings": { + "H": "pane::ActivatePreviousItem", + "L": "pane::ActivateNextItem" + } +} +``` + +**Workflow**: `L` to move right through tabs, `H` to move left. Combine with `space b b` to toggle between last two files. + +## 🎨 Complete Configuration Example + +Here's a full `keymap.json` combining all these patterns: + +```json +[ + { + "context": "Editor && vim_mode == insert && !menu", + "bindings": { + "j j": "vim::NormalBefore", + "j k": "vim::NormalBefore" + } + }, + { + "context": "vim_mode == normal || vim_mode == visual", + "bindings": { + "s": "vim::PushSneak", + "S": "vim::PushSneakBackward" + } + }, + { + "context": "Editor && (vim_mode == normal || vim_mode == visual) && !VimWaiting && !menu", + "bindings": { + // Navigation + "backspace": "pane::GoBack", + "enter": "pane::GoForward", + "shift-backspace": "pane::GoToOlderTag", + "shift-enter": "pane::GoToNewerTag", + "H": "pane::ActivatePreviousItem", + "L": "pane::ActivateNextItem", + + // Git workflow + "space g h d": "editor::ToggleSelectedDiffHunks", + "space g s": "git_panel::ToggleFocus", + "space g b": "git::Branch", + + // Project & Files + "space e": "project_panel::ToggleFocus", + "space f p": "projects::OpenRecent", + + // Search + "space s w": "pane::DeploySearch", + "space s s": "outline::Toggle", + "space s S": "project_symbols::Toggle", + + // Buffers + "space b b": "pane::ActivateLastItem", + "space tab": "pane::ActivateLastItem", + "space q": "pane::CloseActiveItem", + + // AI & Tools + "space a": "agent::ToggleFocus", + "space x x": "diagnostics::Deploy", + + // UI + "space t i": "editor::ToggleInlayHints", + "space z z": "workspace::ToggleZoom" + } + }, + { + "context": "Editor && vim_mode == normal && !VimWaiting && !menu", + "bindings": { + "space .": "editor::ToggleCodeActions", + "space c r": "editor::Rename", + "g d": "editor::GoToDefinition", + "g D": "editor::GoToDefinitionSplit", + "g i": "editor::GoToImplementation", + "g t": "editor::GoToTypeDefinition", + "g r": "editor::FindAllReferences", + "] d": "editor::GoToDiagnostic", + "[ d": "editor::GoToPreviousDiagnostic" + } + } +] +``` + +## πŸ’‘ Pro Tips + +**Muscle Memory**: Practice one category at a time. Start with Git (`space g`), then add Search (`space s`), etc. + +**Consistency**: Keep similar actions across categories (e.g., `space x x` for diagnostics, `space z z` for zoom). + +**Documentation**: Add comments in your config to remember less-used bindings. + +**Integration**: These bindings work together - use `space g s` to open Git panel, then `backspace` to return to editing. + +**Customization**: This is a starting point. Add your own categories and commands based on your workflow. + +## πŸš€ Workflow Examples + +**Code Review**: +1. `space g h d` β†’ View inline diffs +2. Make changes +3. `space g s` β†’ Open Git panel +4. Stage and commit + +**Navigation**: +1. `g d` β†’ Go to definition +2. Explore code +3. `shift-backspace` β†’ Jump back to origin +4. `H` / `L` β†’ Switch between related files + +**Search & Replace**: +1. `space s w` β†’ Search for word under cursor +2. Review results +3. `backspace` β†’ Return to original location + +This configuration transforms Zed into a keyboard-centric powerhouse for Vim users. Every action is optimized for speed and ergonomics!