Skip to content

Conversation

@Juhan280
Copy link

@Juhan280 Juhan280 commented Sep 21, 2025

This PR adds the gg and G motions and adjusts the ^ motion in vi-mode. The gg motion moves the cursor to the first character of the buffer and G moves it to the last. Unlike Vim, these motions do not keep the current column and their interaction with commands like c, d, and y differs because reedline does not support linewise operations. Tests are included for dgg, dG, cgg, and cG.

The ^ motion now moves the cursor to the first non-blank character of the line instead of the line start. Test cases for d^ and c^ are updated accordingly.

Also, the name NonBlankStart could be better. Please tell me if you come up with something better.

This is the first pr I made in rust, if I did any mistake please point it out. Thanks

@Juhan280 Juhan280 force-pushed the vi-mode branch 5 times, most recently from 72bcd81 to 0bcc73d Compare September 30, 2025 15:55
There is a bit of divergence in behaviour of `gg` and `G` motion of
reedline and vim. In vim, these motion maintain the column position of
the cursor, but reedline doesn't. Instead `gg` takes the cursor to the
very first character and `G` takes to the very last character.

Also when using these motion with a command, e.g. `c`, `d` and `y`,
there are some inconsistency in handling the new line character due
reedline not supporting line wise copy unlike vim.

Added test case for `dgg`, `dG`, `cgg` and `cG` command.
Previously the `^` motion was behaving like the `0` motion which is to
move the cursor to the start of the line. But in vim, the `^` motion is
different from `0` motion. In vim `^` moved the cursor to the first
non-blank character of the line. (See `:h ^`)

Updated test case for `d^` and `c^` command since it has different
behaviour now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ViKeybinding Area: Vi(m) keybinding support enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants