diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index a08ff0a9e79fa6aecfb44cfa594e8f1447547665..afee6fcd2e998500ba55e08230473e91e68dbb96 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -207,6 +207,8 @@ "Replace" ], "s": "vim::Substitute", + "> >": "editor::Indent", + "< <": "editor::Outdent", "ctrl-pagedown": "pane::ActivateNextItem", "ctrl-pageup": "pane::ActivatePrevItem" } @@ -302,7 +304,9 @@ "r": [ "vim::PushOperator", "Replace" - ] + ], + "> >": "editor::Indent", + "< <": "editor::Outdent" } }, { @@ -320,4 +324,4 @@ "escape": "editor::Cancel" } } -] \ No newline at end of file +] diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 075229c47fb190a744d08485a25c8a20213c4250..b6c5b7ca51c928072c242ee534bc29c29833878b 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -123,3 +123,19 @@ async fn test_end_of_document_710(cx: &mut gpui::TestAppContext) { cx.simulate_keystrokes(["1", "shift-g"]); cx.assert_editor_state("aˇa\nbb\ncc"); } + +#[gpui::test] +async fn test_indent_outdent(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + + // works in normal mode + cx.set_state(indoc! {"aa\nbˇb\ncc"}, Mode::Normal); + cx.simulate_keystrokes([">", ">"]); + cx.assert_editor_state("aa\n bˇb\ncc"); + cx.simulate_keystrokes(["<", "<"]); + cx.assert_editor_state("aa\nbˇb\ncc"); + + // works in visuial mode + cx.simulate_keystrokes(["shift-v", "down", ">", ">"]); + cx.assert_editor_state("aa\n b«b\n cˇ»c"); +}