Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

JetBrains keymap: Add CamelHump subword navigation (#51540)

loadingalias30f806c4ac51
diff --git a/assets/keymaps/linux/jetbrains.json b/assets/keymaps/linux/jetbrains.json
index 889f89def32..eb6b6df1809 100644
--- a/assets/keymaps/linux/jetbrains.json
+++ b/assets/keymaps/linux/jetbrains.json
@@ -60,6 +60,10 @@
"ctrl-end": "editor::MoveToEnd",
"ctrl-shift-home": "editor::SelectToBeginning",
"ctrl-shift-end": "editor::SelectToEnd",
+ "alt-left": "editor::MoveToPreviousSubwordStart",
+ "alt-right": "editor::MoveToNextSubwordEnd",
+ "shift-alt-left": "editor::SelectToPreviousSubwordStart",
+ "shift-alt-right": "editor::SelectToNextSubwordEnd",
"ctrl-f8": "editor::ToggleBreakpoint",
"ctrl-shift-f8": "editor::EditLogBreakpoint",
"ctrl-shift-u": "editor::ToggleCase",
diff --git a/assets/keymaps/macos/jetbrains.json b/assets/keymaps/macos/jetbrains.json
index 9df47fe2412..5a2f5db448b 100644
--- a/assets/keymaps/macos/jetbrains.json
+++ b/assets/keymaps/macos/jetbrains.json
@@ -59,6 +59,10 @@
"cmd-end": "editor::MoveToEnd",
"cmd-shift-home": "editor::SelectToBeginning",
"cmd-shift-end": "editor::SelectToEnd",
+ "alt-left": "editor::MoveToPreviousSubwordStart",
+ "alt-right": "editor::MoveToNextSubwordEnd",
+ "shift-alt-left": "editor::SelectToPreviousSubwordStart",
+ "shift-alt-right": "editor::SelectToNextSubwordEnd",
"ctrl-f8": "editor::ToggleBreakpoint",
"ctrl-shift-f8": "editor::EditLogBreakpoint",
"cmd-shift-u": "editor::ToggleCase",
diff --git a/docs/src/key-bindings.md b/docs/src/key-bindings.md
index b137d1217e7..1f02b7048fb 100644
--- a/docs/src/key-bindings.md
+++ b/docs/src/key-bindings.md
@@ -305,3 +305,37 @@ For example, `ctrl-n` creates a new tab in Zed on Linux. If you want to send `ct
You can also bind keys to launch Zed Tasks defined in your `tasks.json`.
See the [tasks documentation](tasks.md#custom-keybindings-for-tasks) for more.
+
+### Subword Navigation
+
+Zed exposes word and subword motions as separate actions. Word motions stop at whitespace and punctuation boundaries, while subword motions also stop inside identifiers such as `camelCase`, `PascalCase`, and `snake_case`.
+
+The JetBrains base keymap uses editor-local `alt-left` / `alt-right` and `shift-alt-left` / `shift-alt-right` for subword navigation to match JetBrains-style CamelHump navigation. If you use another base keymap and want that behavior, add this to your `keymap.json`:
+
+```json [keymap]
+[
+ {
+ "context": "Editor",
+ "bindings": {
+ "alt-left": "editor::MoveToPreviousSubwordStart",
+ "alt-right": "editor::MoveToNextSubwordEnd",
+ "shift-alt-left": "editor::SelectToPreviousSubwordStart",
+ "shift-alt-right": "editor::SelectToNextSubwordEnd"
+ }
+ }
+]
+```
+
+If you use the JetBrains base keymap and want `alt-left` / `alt-right` to keep moving between tabs in editors, add this override:
+
+```json [keymap]
+[
+ {
+ "context": "Editor",
+ "bindings": {
+ "alt-left": "pane::ActivatePreviousItem",
+ "alt-right": "pane::ActivateNextItem"
+ }
+ }
+]
+```
diff --git a/docs/src/migrate/intellij.md b/docs/src/migrate/intellij.md
index f09b94d010e..ca200c67257 100644
--- a/docs/src/migrate/intellij.md
+++ b/docs/src/migrate/intellij.md
@@ -43,6 +43,8 @@ If you're coming from IntelliJ, the fastest way to feel at home is to use the Je
This maps familiar shortcuts like `Shift Shift` for Search Everywhere, `Cmd+O` for Go to Class, and `Cmd+Shift+A` for Find Action.
+In editors, the JetBrains keymap also makes `Alt+Left` / `Alt+Right` and `Shift+Alt+Left` / `Shift+Alt+Right` move and select by subword, so identifiers like `camelCase` and `snake_case` behave like IntelliJ's CamelHumps navigation.
+
## Set Up Editor Preferences
You can configure most settings in the Settings Editor ({#kb zed::OpenSettings}). For advanced settings, run {#action zed::OpenSettingsFile} from the Command Palette to edit your settings file directly.
@@ -84,26 +86,28 @@ If you chose the JetBrains keymap during onboarding, most of your shortcuts shou
### Common Shared Keybindings (Zed with JetBrains keymap ↔ IntelliJ)
-| Action | Shortcut |
-| ----------------------------- | ----------------------- |
-| Search Everywhere | `Shift Shift` |
-| Find Action / Command Palette | `Cmd + Shift + A` |
-| Go to File | `Cmd + Shift + O` |
-| Go to Symbol / Class | `Cmd + O` |
-| Recent Files | `Cmd + E` |
-| Go to Definition | `Cmd + B` |
-| Find Usages | `Alt + F7` |
-| Rename Symbol | `Shift + F6` |
-| Reformat Code | `Cmd + Alt + L` |
-| Toggle Project Panel | `Cmd + 1` |
-| Toggle Terminal | `Alt + F12` |
-| Duplicate Line | `Cmd + D` |
-| Delete Line | `Cmd + Backspace` |
-| Move Line Up/Down | `Shift + Alt + Up/Down` |
-| Expand/Shrink Selection | `Alt + Up/Down` |
-| Comment Line | `Cmd + /` |
-| Go Back / Forward | `Cmd + [` / `Cmd + ]` |
-| Toggle Breakpoint | `Ctrl + F8` |
+| Action | Shortcut |
+| ----------------------------- | -------------------------- |
+| Search Everywhere | `Shift Shift` |
+| Find Action / Command Palette | `Cmd + Shift + A` |
+| Go to File | `Cmd + Shift + O` |
+| Go to Symbol / Class | `Cmd + O` |
+| Recent Files | `Cmd + E` |
+| Go to Definition | `Cmd + B` |
+| Find Usages | `Alt + F7` |
+| Rename Symbol | `Shift + F6` |
+| Reformat Code | `Cmd + Alt + L` |
+| Toggle Project Panel | `Cmd + 1` |
+| Toggle Terminal | `Alt + F12` |
+| Duplicate Line | `Cmd + D` |
+| Delete Line | `Cmd + Backspace` |
+| Move Line Up/Down | `Shift + Alt + Up/Down` |
+| Expand/Shrink Selection | `Alt + Up/Down` |
+| Move by subword | `Alt + Left/Right` |
+| Select by subword | `Shift + Alt + Left/Right` |
+| Comment Line | `Cmd + /` |
+| Go Back / Forward | `Cmd + [` / `Cmd + ]` |
+| Toggle Breakpoint | `Ctrl + F8` |
### Different Keybindings (IntelliJ → Zed)
diff --git a/docs/src/migrate/pycharm.md b/docs/src/migrate/pycharm.md
index 2e745cf7d6d..7a6bcf9d17c 100644
--- a/docs/src/migrate/pycharm.md
+++ b/docs/src/migrate/pycharm.md
@@ -43,6 +43,8 @@ If you're coming from PyCharm, the fastest way to feel at home is to use the Jet
This maps familiar shortcuts like `Shift Shift` for Search Everywhere, `Cmd+O` for Go to Class, and `Cmd+Shift+A` for Find Action.
+In editors, the JetBrains keymap also makes `Alt+Left` / `Alt+Right` and `Shift+Alt+Left` / `Shift+Alt+Right` move and select by subword, so identifiers like `camelCase` and `snake_case` behave like PyCharm's CamelHumps navigation.
+
## Set Up Editor Preferences
You can configure most settings in the Settings Editor ({#kb zed::OpenSettings}). For advanced settings, run {#action zed::OpenSettingsFile} from the Command Palette to edit your settings file directly.
@@ -84,26 +86,28 @@ If you chose the JetBrains keymap during onboarding, most of your shortcuts shou
### Common Shared Keybindings
-| Action | Shortcut |
-| ----------------------------- | ----------------------- |
-| Search Everywhere | `Shift Shift` |
-| Find Action / Command Palette | `Cmd + Shift + A` |
-| Go to File | `Cmd + Shift + O` |
-| Go to Symbol | `Cmd + O` |
-| Recent Files | `Cmd + E` |
-| Go to Definition | `Cmd + B` |
-| Find Usages | `Alt + F7` |
-| Rename Symbol | `Shift + F6` |
-| Reformat Code | `Cmd + Alt + L` |
-| Toggle Project Panel | `Cmd + 1` |
-| Toggle Terminal | `Alt + F12` |
-| Duplicate Line | `Cmd + D` |
-| Delete Line | `Cmd + Backspace` |
-| Move Line Up/Down | `Shift + Alt + Up/Down` |
-| Expand/Shrink Selection | `Alt + Up/Down` |
-| Comment Line | `Cmd + /` |
-| Go Back / Forward | `Cmd + [` / `Cmd + ]` |
-| Toggle Breakpoint | `Ctrl + F8` |
+| Action | Shortcut |
+| ----------------------------- | -------------------------- |
+| Search Everywhere | `Shift Shift` |
+| Find Action / Command Palette | `Cmd + Shift + A` |
+| Go to File | `Cmd + Shift + O` |
+| Go to Symbol | `Cmd + O` |
+| Recent Files | `Cmd + E` |
+| Go to Definition | `Cmd + B` |
+| Find Usages | `Alt + F7` |
+| Rename Symbol | `Shift + F6` |
+| Reformat Code | `Cmd + Alt + L` |
+| Toggle Project Panel | `Cmd + 1` |
+| Toggle Terminal | `Alt + F12` |
+| Duplicate Line | `Cmd + D` |
+| Delete Line | `Cmd + Backspace` |
+| Move Line Up/Down | `Shift + Alt + Up/Down` |
+| Expand/Shrink Selection | `Alt + Up/Down` |
+| Move by subword | `Alt + Left/Right` |
+| Select by subword | `Shift + Alt + Left/Right` |
+| Comment Line | `Cmd + /` |
+| Go Back / Forward | `Cmd + [` / `Cmd + ]` |
+| Toggle Breakpoint | `Ctrl + F8` |
### Different Keybindings (PyCharm → Zed)
diff --git a/docs/src/migrate/rustrover.md b/docs/src/migrate/rustrover.md
index 93b54efa1b5..077c441e82a 100644
--- a/docs/src/migrate/rustrover.md
+++ b/docs/src/migrate/rustrover.md
@@ -43,6 +43,8 @@ If you're coming from RustRover, the fastest way to feel at home is to use the J
This maps familiar shortcuts like `Shift Shift` for Search Everywhere, `Cmd+O` for Go to Class, and `Cmd+Shift+A` for Find Action.
+In editors, the JetBrains keymap also makes `Alt+Left` / `Alt+Right` and `Shift+Alt+Left` / `Shift+Alt+Right` move and select by subword, so identifiers like `camelCase` and `snake_case` behave like RustRover's CamelHumps navigation.
+
## Set Up Editor Preferences
You can configure most settings in the Settings Editor ({#kb zed::OpenSettings}). For advanced settings, run {#action zed::OpenSettingsFile} from the Command Palette to edit your settings file directly.
@@ -96,26 +98,28 @@ If you chose the JetBrains keymap during onboarding, most of your shortcuts shou
### Common Shared Keybindings
-| Action | Shortcut |
-| ----------------------------- | ----------------------- |
-| Search Everywhere | `Shift Shift` |
-| Find Action / Command Palette | `Cmd + Shift + A` |
-| Go to File | `Cmd + Shift + O` |
-| Go to Symbol | `Cmd + O` |
-| Recent Files | `Cmd + E` |
-| Go to Definition | `Cmd + B` |
-| Find Usages | `Alt + F7` |
-| Rename Symbol | `Shift + F6` |
-| Reformat Code | `Cmd + Alt + L` |
-| Toggle Project Panel | `Cmd + 1` |
-| Toggle Terminal | `Alt + F12` |
-| Duplicate Line | `Cmd + D` |
-| Delete Line | `Cmd + Backspace` |
-| Move Line Up/Down | `Shift + Alt + Up/Down` |
-| Expand/Shrink Selection | `Alt + Up/Down` |
-| Comment Line | `Cmd + /` |
-| Go Back / Forward | `Cmd + [` / `Cmd + ]` |
-| Toggle Breakpoint | `Ctrl + F8` |
+| Action | Shortcut |
+| ----------------------------- | -------------------------- |
+| Search Everywhere | `Shift Shift` |
+| Find Action / Command Palette | `Cmd + Shift + A` |
+| Go to File | `Cmd + Shift + O` |
+| Go to Symbol | `Cmd + O` |
+| Recent Files | `Cmd + E` |
+| Go to Definition | `Cmd + B` |
+| Find Usages | `Alt + F7` |
+| Rename Symbol | `Shift + F6` |
+| Reformat Code | `Cmd + Alt + L` |
+| Toggle Project Panel | `Cmd + 1` |
+| Toggle Terminal | `Alt + F12` |
+| Duplicate Line | `Cmd + D` |
+| Delete Line | `Cmd + Backspace` |
+| Move Line Up/Down | `Shift + Alt + Up/Down` |
+| Expand/Shrink Selection | `Alt + Up/Down` |
+| Move by subword | `Alt + Left/Right` |
+| Select by subword | `Shift + Alt + Left/Right` |
+| Comment Line | `Cmd + /` |
+| Go Back / Forward | `Cmd + [` / `Cmd + ]` |
+| Toggle Breakpoint | `Ctrl + F8` |
### Different Keybindings (RustRover → Zed)
diff --git a/docs/src/migrate/webstorm.md b/docs/src/migrate/webstorm.md
index 023f8e2a59d..fc464def5c1 100644
--- a/docs/src/migrate/webstorm.md
+++ b/docs/src/migrate/webstorm.md
@@ -43,6 +43,8 @@ If you're coming from WebStorm, the fastest way to feel at home is to use the Je
This maps familiar shortcuts like {#kb:jetbrains project_symbols::Toggle} for Go to Class and {#kb:jetbrains command_palette::Toggle} for Find Action.
+In editors, the JetBrains keymap also makes `Alt+Left` / `Alt+Right` and `Shift+Alt+Left` / `Shift+Alt+Right` move and select by subword, so identifiers like `camelCase` and `snake_case` behave like WebStorm's CamelHumps navigation.
+
## Set Up Editor Preferences
You can configure most settings in the Settings Editor ({#kb zed::OpenSettings}). For advanced settings, run {#action zed::OpenSettingsFile} from the Command Palette to edit your settings file directly.
@@ -82,31 +84,40 @@ Open buffers appear as tabs across the top. The Project Panel shows your file tr
If you chose the JetBrains keymap during onboarding, most of your shortcuts should already feel familiar. Here's a quick reference of common actions and their keybindings with the JetBrains keymap active.
-### Common Keybindings
-
-| Action | Zed Keybinding |
-| ---------------------- | ----------------------------------------------- |
-| Command Palette | {#kb:jetbrains command_palette::Toggle} |
-| Go to File | {#kb:jetbrains file_finder::Toggle} |
-| Go to Symbol | {#kb:jetbrains project_symbols::Toggle} |
-| File Outline | {#kb:jetbrains outline::Toggle} |
-| Go to Definition | {#kb:jetbrains editor::GoToDefinition} |
-| Find Usages | {#kb:jetbrains editor::FindAllReferences} |
-| Rename Symbol | {#kb:jetbrains editor::Rename} |
-| Reformat Code | {#kb:jetbrains editor::Format} |
-| Toggle Project Panel | {#kb:jetbrains project_panel::ToggleFocus} |
-| Toggle Terminal | {#kb:jetbrains terminal_panel::Toggle} |
-| Duplicate Line | {#kb:jetbrains editor::DuplicateSelection} |
-| Delete Line | {#kb:jetbrains editor::DeleteLine} |
-| Move Line Up | {#kb:jetbrains editor::MoveLineUp} |
-| Move Line Down | {#kb:jetbrains editor::MoveLineDown} |
-| Expand Selection | {#kb:jetbrains editor::SelectLargerSyntaxNode} |
-| Shrink Selection | {#kb:jetbrains editor::SelectSmallerSyntaxNode} |
-| Comment Line | {#kb:jetbrains editor::ToggleComments} |
-| Go Back | {#kb:jetbrains pane::GoBack} |
-| Go Forward | {#kb:jetbrains pane::GoForward} |
-| Toggle Breakpoint | {#kb:jetbrains editor::ToggleBreakpoint} |
-| Navigate to Next Error | {#kb:jetbrains editor::GoToDiagnostic} |
+### Common Shared Keybindings
+
+| Action | Zed Keybinding |
+| ----------------------------- | ----------------------------------------------------------------------------------------------------- |
+| Search Everywhere | {#kb:jetbrains command_palette::Toggle} |
+| Find Action / Command Palette | {#kb:jetbrains command_palette::Toggle} |
+| Go to File | {#kb:jetbrains file_finder::Toggle} |
+| Go to Symbol | {#kb:jetbrains project_symbols::Toggle} |
+| Recent Files | {#kb:jetbrains file_finder::Toggle} |
+| Go to Definition | {#kb:jetbrains editor::GoToDefinition} |
+| Find Usages | {#kb:jetbrains editor::FindAllReferences} |
+| Rename Symbol | {#kb:jetbrains editor::Rename} |
+| Reformat Code | {#kb:jetbrains editor::Format} |
+| Toggle Project Panel | {#kb:jetbrains project_panel::ToggleFocus} |
+| Toggle Terminal | {#kb:jetbrains terminal_panel::Toggle} |
+| Duplicate Line | {#kb:jetbrains editor::DuplicateSelection} |
+| Delete Line | {#kb:jetbrains editor::DeleteLine} |
+| Move Line Up/Down | {#kb:jetbrains editor::MoveLineUp} / {#kb:jetbrains editor::MoveLineDown} |
+| Expand/Shrink Selection | {#kb:jetbrains editor::SelectLargerSyntaxNode} / {#kb:jetbrains editor::SelectSmallerSyntaxNode} |
+| Move by subword | {#kb:jetbrains editor::MoveToPreviousSubwordStart} / {#kb:jetbrains editor::MoveToNextSubwordEnd} |
+| Select by subword | {#kb:jetbrains editor::SelectToPreviousSubwordStart} / {#kb:jetbrains editor::SelectToNextSubwordEnd} |
+| Comment Line | {#kb:jetbrains editor::ToggleComments} |
+| Go Back / Forward | {#kb:jetbrains pane::GoBack} / {#kb:jetbrains pane::GoForward} |
+| Toggle Breakpoint | {#kb:jetbrains editor::ToggleBreakpoint} |
+
+### Different Keybindings (WebStorm → Zed)
+
+| Action | WebStorm | Zed (JetBrains keymap) |
+| ---------------------- | ----------- | ------------------------ |
+| File Structure | `Cmd + F12` | `Cmd + F12` (outline) |
+| Navigate to Next Error | `F2` | `F2` |
+| Run | `Ctrl + R` | `Ctrl + Alt + R` (tasks) |
+| Debug | `Ctrl + D` | `Alt + Shift + F9` |
+| Stop | `Cmd + F2` | `Ctrl + F2` |
### Unique to Zed