diff --git a/src/command.rs b/src/command.rs index c16f9669f..652e9f1c0 100644 --- a/src/command.rs +++ b/src/command.rs @@ -51,7 +51,9 @@ pub fn execute( } Cmd::Move(Movement::ViFirstPrint) => { s.edit_move_home()?; - s.edit_move_to_next_word(At::Start, Word::Big, 1)?; + if s.line.starts_with(char::is_whitespace) { + s.edit_move_to_next_word(At::Start, Word::Big, 1)?; + } } Cmd::Move(Movement::BackwardChar(n)) => { // Move back a character. diff --git a/src/test/vi_cmd.rs b/src/test/vi_cmd.rs index be8437d2d..c8ff89b2f 100644 --- a/src/test/vi_cmd.rs +++ b/src/test/vi_cmd.rs @@ -58,6 +58,16 @@ fn caret() { ); } +#[test] +fn caret_no_whitespace() { + assert_cursor( + EditMode::Vi, + ("Hi", ""), + &[E::ESC, E::from('^'), E::ENTER], + ("", "Hi"), + ); +} + #[test] fn a() { assert_cursor(