A pretty new and fast editor written in Rust by the authors of Atom and Electron, a team that used to work at GitHub.It’s elegant, efficient and powerful. As with most of my recent articles, I’ll be covering the main keyboard shortcuts and features I’m currently using. Zed is still young, so I’ll probably come back to it when, for example, the Git integration is improved. I also still need to work on the equivalent hotkeys for Windows and Linux. So stay tuned.
Cheatsheet
Main
Action | macOS | Windows/Linux |
---|---|---|
open command palette | Cmd Shift p |
CtrlS Shift p |
go to File* | Cmd p Space f |
Ctrl p |
go to pane 1 2 3 | Cmd 1 2 3 |
alt 1 2 3 |
move tab left or right | Cmd Shift [ or ] |
|
tab switcher | Ctrl Tab |
Ctrl Tab |
toggle terminal* | Cmd t |
|
toggle sidebar* | Ctrl s Space e |
*
mean I’ve added them to my keymap.json
Windows
Action | macOS | Windows/Linux |
---|---|---|
activate left right up down | space ← → ↑ ↓ |
|
Split Vertical* | space v |
|
Close pane | space c |
|
max/min pane* | space z space shift-z |
Editor
Action | macOS | Windows/Linux |
---|---|---|
increase, decrease, reset font size | Cmd + - 0 |
|
find in File | Cmd f |
Ctrl f |
find in Project | Cmd Shift f |
Ctrl Shift f |
toggle comments | Cmd / |
|
joins Lines* | Ctrl j |
|
add cursors up down | Ctrl Shift ↑ ↓ |
|
move line up down | Cmd Ctrl ↑ ↓ |
|
multi cursor in normal mode | <number> g l |
|
go to line | Ctrl G |
📜 Go specific features
As most editor, Zed natively leverage gopls, the Go language server to second you while coding. You just have to install gopls to enjoy the shortcut of this section
go install golang.org/x/tools/gopls@latest
which gopls
Action | macOS | Windows/Linux |
---|---|---|
Auto-Format on Save Format Document |
Cmd S Cmd Shift P → “Format Document” |
Ctrl S |
Go to Definition | Cmd Click or F12 |
Ctrl Click or F12 |
Go to Symbol | Cmd Shift O |
Ctrl Shift O |
Show Quick Fixes | Cmd . |
Ctrl . |
ToggleInlayHints | space t i |
Zed supports hundreds of other programming languages and text formats.
Configuration
Action | macOS | Windows/Linux |
---|---|---|
Settings | Cmd , |
Ctrl , |
Keybindings config | Cmd k Cmd s |
|
default keybindings | Cmd Shift default key |
|
extensions | Cmd Shift x |
|
toggle language selector | Cmd k m |
🌱 Git Integration XXX
Action | macOS | Windows/Linux |
---|---|---|
Open Git Panel | Cmd Shift G |
Ctrl Shift G |
Commit Changes | Cmd Enter (inside Git panel) |
Ctrl Enter (inside Git panel) |
Push/Pull | Use Git panel | Use Git panel |
Tasks
A Zed task is a command that you can run from within it using spawn
or by simply assigning a keymap. All the Task like everything else in Zed is accessible from the command Palette
Action | macOS | Windows/Linux |
---|---|---|
execute a task | Space t e |
|
rerun a task | Space t r |
|
edit project tasks into .zed/tasks.json | Cmd Shift p proj task |
|
edit tasks | Cmd Shift p open task |
The current tasks I configured at this staged
// Static tasks configuration.
[
{
"label": "Go: run",
"command": "go run .",
"use_new_terminal": false,
"reveal": "always",
"allow_concurrent_runs": false
},
{
"label": "Go: test",
"command": "go test ./...",
"use_new_terminal": false,
"reveal": "always",
"allow_concurrent_runs": false
},
{
"label": "Go: build",
"command": "go build .",
"use_new_terminal": false,
"reveal": "always",
"allow_concurrent_runs": false
},
{
"label": "Go: tidy",
"command": "go mod tidy",
"use_new_terminal": false,
"reveal": "always",
"allow_concurrent_runs": false
},
{
"label": "Go: init",
"command": "go mod init",
"use_new_terminal": false,
"reveal": "always",
"allow_concurrent_runs": false
},
{
"label": "Go: test a function",
"command": "go test -run $ZED_SYMBOL $ZED_FILE",
"use_new_terminal": false,
"reveal": "always",
"allow_concurrent_runs": false
},
{
"label": "TEMPL: generate",
"command": "templ generate",
"use_new_terminal": false,
"reveal": "always",
"allow_concurrent_runs": false
},
{
"label": "Go: modd",
"command": "modd",
"use_new_terminal": false,
"reveal": "never",
"allow_concurrent_runs": false
}
]
Keymaps
Open default Keymap
cmd+shift+p open default keymap
Config file
read on macos from ~/.zed/keymap.json
read on Linux from ~/.config/zed/keymap.json
syntax
ctrl
The control keycmd
,win
orsuper
for the platform modifier (Command on macOS, Windows key on Windows, and the Super key on Linux).alt
for alt (option on macOS)shift
The shift keyfn
The function key
My Config
My current keymap file contain the following custom hotkeys.
// Zed keymap
//
// For information on binding keys, see the Zed
// documentation: https://zed.dev/docs/key-bindings
//
// To see the default key bindings run `zed: open default keymap`
// from the command palette.
[
{
"context": "Workspace",
"bindings": {
"cmd-t": "terminal_panel::ToggleFocus",
"ctrl-s": "workspace::ToggleLeftDock"
}
},
{
"context": "Editor",
"bindings": {
// "j k": ["workspace::SendKeystrokes", "escape"]
"ctrl-j": "editor::JoinLines"
}
},
{
"context": "EmptyPane || SharedScreen || vim_operator == none && !VimWaiting && vim_mode != insert",
"bindings": {
"space t e": "task::Spawn",
"space t r": ["task::Rerun", { "reevaluate_context": true }],
"space f": "file_finder::Toggle",
"space e": "workspace::ToggleLeftDock",
"space v": "pane::SplitRight",
"space c": "pane::CloseActiveItem",
"space z": "vim::MaximizePane",
"space t i": "editor::ToggleInlayHints",
"space shift-z": "vim::ResetPaneSizes",
"space left": ["workspace::ActivatePaneInDirection", "Left"],
"space right": ["workspace::ActivatePaneInDirection", "Right"],
"space up": ["workspace::ActivatePaneInDirection", "Up"],
"space down": ["workspace::ActivatePaneInDirection", "Down"]
}
},
{
"context": "Terminal",
"bindings": {
"cmd-t": "workspace::ToggleBottomDock",
"cmd-n": "workspace::NewTerminal"
}
},
{
"context": "ProjectPanel",
"bindings": {
"space e": "workspace::ToggleLeftDock"
}
}
]
make sure vim_mode is true in your settings
SSH
Zed offers an ability to work on code hosted remotely provided you have access to the distant host thru SSH
- Connect to a remote server using
Ctrl Cmd O
and clickConnect New Server
- Zed will connect over SSH download the binary and start it
- You’ll then be prompted with a
PATH
You can also open a remote path like this
zed ssh://[<user>@]<host>[:<port>]/<path>
gopls
Make sure you install gopls
like this instead of using your operating system package or homebrew. If you’ve already installed it like this just uninstall and re-install.
go install golang.org/x/tools/gopls@latest
Zed should automatically detect gopls
and provide features like:
- Auto-completion
- Hover documentation
- Go-to definition
- Error checking
- Format code on save
Git
Zed currently only support, more to come
- Diff indicators in buffers and editor scrollbars
- Inline diff toggle and reverts in the editor for unstaged changes
- Git status in the project panel
- Branch creating and switching
- Git blame viewing
Links
- default keymaps macos