diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 211cbcf9266f0a..238ba4ffe5f464 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -293,6 +293,7 @@ "!": "vim::ShellCommand", "i": ["vim::PushObject", { "around": false }], "a": ["vim::PushObject", { "around": true }], + "g r": ["vim::Paste", { "preserve_clipboard": true }], "g c": "vim::ToggleComments", "g q": "vim::Rewrap", "\"": "vim::PushRegister", diff --git a/crates/vim/src/normal/paste.rs b/crates/vim/src/normal/paste.rs index 261b137b14d61b..883fb33c65170d 100644 --- a/crates/vim/src/normal/paste.rs +++ b/crates/vim/src/normal/paste.rs @@ -849,6 +849,26 @@ mod test { ); let clipboard: Register = cx.read_from_clipboard().unwrap().into(); assert_eq!(clipboard.text, "fish"); + + cx.set_state( + indoc! {" + ˇfish one + two three + "}, + Mode::Normal, + ); + cx.simulate_keystrokes("y i w"); + cx.simulate_keystrokes("w"); + cx.simulate_keystrokes("v i w g r"); + cx.assert_state( + indoc! {" + fish fisˇh + two three + "}, + Mode::Normal, + ); + let clipboard: Register = cx.read_from_clipboard().unwrap().into(); + assert_eq!(clipboard.text, "fish"); } #[gpui::test]