diff --git a/docs/src/all-actions.md b/docs/src/all-actions.md deleted file mode 100644 index e5a45a8fd8d5926e657d6ad35234fd14d4853952..0000000000000000000000000000000000000000 --- a/docs/src/all-actions.md +++ /dev/null @@ -1,3 +0,0 @@ -# All Actions - -{#ACTIONS_TABLE#} diff --git a/docs/src/command-line-interface.md b/docs/src/command-line-interface.md deleted file mode 100644 index 1a7831811dd119357c7f076be3fe9efa35bce021..0000000000000000000000000000000000000000 --- a/docs/src/command-line-interface.md +++ /dev/null @@ -1,18 +0,0 @@ -# Command-line Interface - -Zed has a CLI, on Linux this should come with the distribution's Zed package (binary name can vary from distribution to distribution, `zed` will be used later for brevity). -For macOS, the CLI comes in the same package with the editor binary, and could be installed into the system with the `cli: install` Zed command which will create a symlink to the `/usr/local/bin/zed`. -It can also be built from source out of the `cli` crate in this repository. - -Use `zed --help` to see the full list of capabilities. -General highlights: - -- Opening another empty Zed window: `zed` - -- Opening a file or directory in Zed: `zed /path/to/entry` (use `-n` to open in the new window) - -- Reading from stdin: `ps axf | zed -` - -- Starting Zed with logs in the terminal: `zed --foreground` - -- Uninstalling Zed and all its related files: `zed --uninstall` diff --git a/docs/src/environment.md b/docs/src/environment.md deleted file mode 100644 index 41980b2d96f5109776028392625e2e4642fa9022..0000000000000000000000000000000000000000 --- a/docs/src/environment.md +++ /dev/null @@ -1,92 +0,0 @@ -# Environment Variables - -_**Note**: The following only applies to Zed 0.152.0 and later._ - -Multiple features in Zed are affected by environment variables: - -- Tasks -- Built-in terminal -- Look-up of language servers -- Language servers - -In order to make the best use of these features, it's helpful to understand where Zed gets its environment variables from and how they're used. - -## Where does Zed get its environment variables from? - -How Zed was started — whether it's icon was clicked in the macOS Dock or in a Linux window manager, or whether it was started via the CLI `zed` that comes with Zed — influences which environment variables Zed can use. - -### Launched from the CLI - -If Zed is opened via the CLI (`zed`), it will inherit the environment variables from the surrounding shell session. - -That means if you do - -``` -$ export MY_ENV_VAR=hello -$ zed . -``` - -the environment variable `MY_ENV_VAR` is now available inside Zed. For example, in the built-in terminal. - -Starting with Zed 0.152.0, the CLI `zed` will _always_ pass along its environment to Zed, regardless of whether a Zed instance was previously running or not. Prior to Zed 0.152.0 this was not the case and only the first Zed instance would inherit the environment variables. - -### Launched via window manager, Dock, or launcher - -When Zed has been launched via the macOS Dock, or a GNOME or KDE icon on Linux, or an application launcher like Alfred or Raycast, it has no surrounding shell environment from which to inherit its environment variables. - -In order to still have a useful environment, Zed spawns a login shell in the user's home directory and gets its environment. This environment is then set on the Zed _process_. That means all Zed windows and projects will inherit that home directory environment. - -Since that can lead to problems for users that require different environment variables for a project (because they use `direnv`, or `asdf`, or `mise`, ... in that project), when opening project, Zed spawns another login shell. This time in the project's directory. The environment from that login shell is _not_ set on the process (because that would mean opening a new project changes the environment for all Zed windows). Instead, the environment is stored and passed along when running tasks, opening terminals, or spawning language servers. - -## Where and how are environment variables used? - -There are two sets of environment variables: - -1. Environment variables of the Zed process -2. Environment variables stored per project - -The variables from (1) are always used, since they are stored on the process itself and every spawned process (tasks, terminals, language servers, ...) will inherit them by default. - -The variables from (2) are used explicitly, depending on the feature. - -### Tasks - -Tasks are spawned with an combined environment. In order of precedence (low to high, with the last overwriting the first): - -- the Zed process environment -- if the project was opened from the CLI: the CLI environment -- if the project was not opened from the CLI: the project environment variables obtained by running a login shell in the project's root folder -- optional, explicitly configured environment in settings - -### Built-in terminal - -Built-in terminals, like tasks, are spawned with an combined environment. In order of precedence (low to high): - -- the Zed process environment -- if the project was opened from the CLI: the CLI environment -- if the project was not opened from the CLI: the project environment variables obtained by running a login shell in the project's root folder -- optional, explicitly configured environment in settings - -### Look-up of language servers - -For some languages the language server adapters lookup the binary in the user's `$PATH`. Examples: - -- Go -- Zig -- Rust (if [configured to do so](./languages/rust.md#binary)) -- C -- TypeScript - -For this look-up, Zed uses the following the environment: - -- if the project was opened from the CLI: the CLI environment -- if the project was not opened from the CLI: the project environment variables obtained by running a login shell in the project's root folder - -### Language servers - -After looking up a language server, Zed starts them. - -These language server processes always inherit Zed's process environment. But, depending on the language server look-up, additional environment variables might be set or overwrite the process environment. - -- If the language server was found in the project environment's `$PATH`, then the project environment's is passed along to the language server process. Where the project environment comes from depends on how the project was opened, via CLI or not. See previous point on look-up of language servers. -- If the language servers was not found in the project environment, Zed tries to install it globally and start it globally. In that case, the process will inherit Zed's process environment, and — if the project was opened via ClI — from the CLI. diff --git a/docs/src/globs.md b/docs/src/globs.md deleted file mode 100644 index 2f86fb9158f6ef13b5922a988dc3fa3433c42221..0000000000000000000000000000000000000000 --- a/docs/src/globs.md +++ /dev/null @@ -1,80 +0,0 @@ -# Globs - -Zed supports the use of [glob]() patterns that are the formal name for Unix shell-style path matching wildcards like `*.md` or `docs/src/**/*.md` supported by sh, bash, zsh, etc. A glob is similar but distinct from a [regex (regular expression)](https://en.wikipedia.org/wiki/Regular_expression). You may be In Zed these are commonly used when matching filenames. - -## Glob Flavor - -Zed uses two different rust crates for matching glob patterns: - -- [ignore crate](https://docs.rs/ignore/latest/ignore/) for matching glob patterns stored in `.gitignore` files -- [glob crate](https://docs.rs/glob/latest/glob/) for matching file paths in Zed - -While simple expressions are portable across environments (e.g. running `ls *.py` or `*.tmp` in a gitignore) there is significant divergence in the support for and syntax of more advanced features varies (character classes, exclusions, `**`, etc) across implementations. For the rest of this document we will be describing globs as supported in Zed via the `glob` crate implementation. Please see [References](#references) below for documentation links for glob pattern syntax for `.gitignore`, shells and other programming languages. - -The `glob` crate is implemented entirely in rust and does not rely on the `glob` / `fnmatch` interfaces provided by your platforms libc. This means that globs in Zed should behave similarly with across platforms. - -## Introduction - -A glob "pattern" is used to match a file name or complete file path. For example, when using "Search all files" {#kb project_search::ToggleFocus} you can click the funnel shaped Toggle Filters" button or {#kb project_search::ToggleFilters} and it will show additional search fields for "Include" and "Exclude" which support specifying glob patterns for matching file paths and file names. - -When creating a glob pattern you can use one or multiple special characters: - -| Special Character | Meaning | -| ----------------- | ----------------------------------------------------------------- | -| `?` | Matches any single character | -| `*` | Matches any (possibly empty) sequence of characters | -| `**` | Matches the current directory and arbitrary subdirectories | -| `[abc]` | Matches any one character in the brackets | -| `[a-z]` | Matches any of a range of characters (ordered by Unicode) | -| `[!...]` | The negation of `[...]` (matches a character not in the brackets) | - -Notes: - -1. Shell-style brace-expansions like `{a,b,c}` are not supported. -2. To match a literal `-` character inside brackets it must come first `[-abc]` or last `[abc-]`. -3. To match the literal `[` character use `[[]` or put it as the first character in the group `[[abc]`. -4. To match the literal `]` character use `[]]` or put it as the last character in the group `[abc]]`. - -## Examples - -### Matching file extensions - -If you wanted to only search Markdown files add `*.md` to the "Include" search field. - -### Case insensitive matching - -Globs in Zed are case-sensitive, so `*.c` will not match `main.C` (even on case-insensitive filesystems like HFS+/APFS on macOS). Instead use brackets to match characters. So instead of `*.c` use `*.[cC]`. - -### Matching directories - -If you wanted to search the [zed repository](https://github.com/zed-industries/zed) for examples of [Configuring Language Servers](https://zed.dev/docs/configuring-languages#configuring-language-servers) (under `"lsp"` in Zed settings.json) you could search for `"lsp"` and in the "Include" filter specify `docs/**/*.md`. This would only match files whose path was under the `docs` directory or any nested subdirectories `**/` of that folder with a filename that ends in `.md`. - -If instead you wanted to restrict yourself only to [Zed Language-Specific Documentation](https://zed.dev/docs/languages) pages you could define a narrower pattern of: `docs/src/languages/*.md` this would match [`docs/src/languages/rust.md`](https://github.com/zed-industries/zed/blob/main/docs/src/languages/rust.md) and [`docs/src/languages/cpp.md`](https://github.com/zed-industries/zed/blob/main/docs/src/languages/cpp.md) but not [`docs/src/configuring-languages.md`](https://github.com/zed-industries/zed/blob/main/docs/src/configuring-languages.md). - -### Implicit Wildcards - -When using the "Include" / "Exclude" filters on a Project Search each glob is wrapped in implicit wildcards. For example to exclude any files with license in the path or filename from your search just type `license` in the exclude box. Behind the scenes Zed transforms `license` to `**license**`. This means that files named `license.*`, `*.license` or inside a `license` subdirectory will all be filtered out. This enables users to easily filter for `*.ts` without having to remember to type `**/*.ts` every time. - -Alternatively, if in your Zed settings you wanted a [`file_types`](./configuring-zed.md#file-types) override which only applied to a certain directory you must explicitly include the wildcard globs. For example, if you had a directory of template files with the `html` extension that you wanted to recognize as Jinja2 template you could use the following: - -```json [settings] -{ - "file_types": { - "C++": ["[cC]"], - "Jinja2": ["**/templates/*.html"] - } -} -``` - -## References - -While globs in Zed are implemented as described above, when writing code using globs in other languages, please reference your platform's glob documentation: - -- [macOS fnmatch](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/fnmatch.3.html) (BSD C Standard Library) -- [Linux fnmatch](https://www.gnu.org/software/libc/manual/html_node/Wildcard-Matching.html) (GNU C Standard Library) -- [POSIX fnmatch](https://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html) (POSIX Specification) -- [node-glob](https://github.com/isaacs/node-glob) (Node.js `glob` package) -- [Python glob](https://docs.python.org/3/library/glob.html) (Python Standard Library) -- [Golang glob](https://pkg.go.dev/path/filepath#Match) (Go Standard Library) -- [gitignore patterns](https://git-scm.com/docs/gitignore) (Gitignore Pattern Format) -- [PowerShell: About Wildcards](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_wildcards) (Wildcards in PowerShell) diff --git a/docs/src/reference/cli.md b/docs/src/reference/cli.md index 2b44792dace53af1b0081458aafb8d62e5864371..52f21b2f3ea4de97c0f8fb219f2afd93bb41e75f 100644 --- a/docs/src/reference/cli.md +++ b/docs/src/reference/cli.md @@ -29,15 +29,18 @@ zed [OPTIONS] [PATHS...] | Option | Description | |--------|-------------| -| `-n`, `--new` | Open in a new window instead of reusing an existing one | -| `-w`, `--wait` | Wait for the file to be closed before returning | -| `-a`, `--add` | Add files to the current workspace | +| `-w`, `--wait` | Wait for all given paths to be opened/closed before exiting | +| `-a`, `--add` | Add files to the currently open workspace | +| `-n`, `--new` | Create a new workspace | +| `-r`, `--reuse` | Reuse an existing window, replacing its workspace | | `-` | Read from stdin | -| `--foreground` | Start Zed with logs output to the terminal | -| `--dev-server-token ` | Start as a dev server with the given token | -| `--uninstall` | Uninstall Zed and all related files | -| `-h`, `--help` | Show help information | -| `-v`, `--version` | Show version information | +| `--foreground` | Run Zed in the foreground (useful for debugging, shows all logs) | +| `--zed ` | Custom path to Zed.app or the zed binary | +| `--dev-server-token ` | Run Zed in dev-server mode with the given token | +| `--diff ` | Open a diff view comparing two files (can be used multiple times) | +| `--user-data-dir ` | Set a custom directory for all user data (database, extensions, logs) | +| `--uninstall` | Uninstall Zed and all related files (Linux/macOS only) | +| `--version` | Print Zed's version and the app path | ## Opening Files at a Specific Line @@ -73,3 +76,15 @@ Open multiple files in a new window: ```sh zed -n src/main.rs src/lib.rs ``` + +Compare two files: + +```sh +zed --diff old_version.rs new_version.rs +``` + +Add files to an existing workspace: + +```sh +zed -a additional_file.rs +``` diff --git a/docs/src/reference/default-key-bindings.md b/docs/src/reference/default-key-bindings.md index a2fc1f879babcab4a9ab5d4e16b8a549f68f7450..a03d2f9eaaffdcc7d70ee57453ecec01e7674d24 100644 --- a/docs/src/reference/default-key-bindings.md +++ b/docs/src/reference/default-key-bindings.md @@ -37,8 +37,9 @@ These are the most commonly used default bindings. Platform-specific keys are sh | Undo | `Cmd+Z` | `Ctrl+Z` | | Redo | `Cmd+Shift+Z` | `Ctrl+Shift+Z` | | Save | `Cmd+S` | `Ctrl+S` | -| Find | `Cmd+F` | `Ctrl+F` | -| Find and replace | `Cmd+H` | `Ctrl+H` | +| Find in buffer | `Cmd+F` | `Ctrl+F` | +| Replace in buffer | `Cmd+Alt+F` | `Ctrl+H` | +| Project search with replace | `Cmd+Shift+H` | `Ctrl+Shift+H` | | Comment line | `Cmd+/` | `Ctrl+/` | | Format document | `Cmd+Shift+I` | `Ctrl+Shift+I` | @@ -47,18 +48,19 @@ These are the most commonly used default bindings. Platform-specific keys are sh | Action | macOS | Linux/Windows | |--------|-------|---------------| | Go to line | `Ctrl+G` | `Ctrl+G` | -| Go to definition | `F12` or `Cmd+Click` | `F12` or `Ctrl+Click` | -| Go to references | `Shift+F12` | `Shift+F12` | -| Go to symbol | `Cmd+Shift+O` | `Ctrl+Shift+O` | -| Go back | `Ctrl+-` | `Alt+Left` | -| Go forward | `Ctrl+Shift+-` | `Alt+Right` | +| Go to definition | `F12` | `F12` | +| Go to implementation | `Shift+F12` | `Shift+F12` (Linux), `Ctrl+F12` (Windows) | +| Find all references | `Alt+Shift+F12` | `Alt+Shift+F12` (Linux), `Shift+Alt+F12` (Windows) | +| Go to symbol in file | `Cmd+Shift+O` | `Ctrl+Shift+O` | +| Go back | `Ctrl+-` | `Ctrl+Alt+-` (Linux), `Alt+Left` (Windows) | +| Go forward | `Ctrl+_` | `Ctrl+Alt+_` (Linux), `Alt+Right` (Windows) | ### Multi-cursor | Action | macOS | Linux/Windows | |--------|-------|---------------| -| Add cursor above | `Cmd+Alt+Up` | `Ctrl+Alt+Up` | -| Add cursor below | `Cmd+Alt+Down` | `Ctrl+Alt+Down` | +| Add cursor above | `Cmd+Alt+Up` | `Shift+Alt+Up` (Linux), `Ctrl+Alt+Up` (Windows) | +| Add cursor below | `Cmd+Alt+Down` | `Shift+Alt+Down` (Linux), `Ctrl+Alt+Down` (Windows) | | Select next occurrence | `Cmd+D` | `Ctrl+D` | | Select all occurrences | `Cmd+Shift+L` | `Ctrl+Shift+L` | @@ -67,13 +69,15 @@ These are the most commonly used default bindings. Platform-specific keys are sh | Action | macOS | Linux/Windows | |--------|-------|---------------| | Project panel | `Cmd+Shift+E` | `Ctrl+Shift+E` | -| Outline panel | `Cmd+Shift+O` | `Ctrl+Shift+O` | -| Git panel | `Cmd+Shift+G` | `Ctrl+Shift+G` | -| Agent panel | `Cmd+Shift+A` | `Ctrl+Shift+A` | +| Outline panel | `Cmd+Shift+B` | `Ctrl+Shift+B` | +| Git panel | `Ctrl+Shift+G` | `Ctrl+Shift+G` | +| Agent panel | `Cmd+?` | `Ctrl+?` (Linux), `Ctrl+Shift+/` (Windows) | ## Predefined Keymaps -If you prefer another editor's bindings, change the `base_keymap` setting: +If you prefer another editor's bindings, open the Settings Editor (`Cmd+,` on macOS, `Ctrl+,` on Linux/Windows) and search for `base_keymap`. Select your preferred keymap from the dropdown. + +Or add this to your settings.json: ```json { @@ -83,11 +87,11 @@ If you prefer another editor's bindings, change the `base_keymap` setting: Available options: - `VSCode` (default) -- `Atom` -- `Emacs` - `JetBrains` - `SublimeText` +- `Atom` - `TextMate` +- `Emacs` - `Cursor` - `None`