Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use `alt-z` to toggle soft wrap in active editor
Antonio Scandurra4a2b7e48209a
diff --git a/assets/keymaps/default.json b/assets/keymaps/default.jsonindex 17168f679f7..1d324fe582f 100644--- a/assets/keymaps/default.json+++ b/assets/keymaps/default.json@@ -164,6 +164,7 @@"bindings": {"enter": "editor::Newline","cmd-enter": "editor::NewlineBelow",+ "alt-z": "editor::ToggleSoftWrap","cmd-f": ["buffer_search::Deploy",{diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 8ab02db130b..db357f2b839 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -236,6 +236,7 @@ actions!(RestartLanguageServer,Hover,Format,+ ToggleSoftWrap]);@@ -346,6 +347,7 @@ pub fn init(cx: &mut MutableAppContext) {cx.add_action(Editor::toggle_code_actions);cx.add_action(Editor::open_excerpts);cx.add_action(Editor::jump);+ cx.add_action(Editor::toggle_soft_wrap);cx.add_async_action(Editor::format);cx.add_action(Editor::restart_language_server);cx.add_action(Editor::show_character_palette);@@ -5812,6 +5814,19 @@ impl Editor {.update(cx, |map, cx| map.set_wrap_width(width, cx))}+ pub fn toggle_soft_wrap(&mut self, _: &ToggleSoftWrap, cx: &mut ViewContext<Self>) {+ if self.soft_wrap_mode_override.is_some() {+ self.soft_wrap_mode_override.take();+ } else {+ let soft_wrap = match self.soft_wrap_mode(cx) {+ SoftWrap::None => settings::SoftWrap::EditorWidth,+ SoftWrap::EditorWidth | SoftWrap::Column(_) => settings::SoftWrap::None,+ };+ self.soft_wrap_mode_override = Some(soft_wrap);+ }+ cx.notify();+ }+pub fn highlight_rows(&mut self, rows: Option<Range<u32>>) {self.highlighted_rows = rows;}