Open guhan-balaji opened 3 years ago
It shouldn't display -- REPLACE --
, as r
doesn't put you in Replace mode, you remain in Normal mode. Neovim does change the cursor though, we should probably replicate that behavior.
Yes, please, the cursor when doing r
should change like when doing R
, as vim does. Thanks!!
I've been exploring the code a little and differentiate the cursor for r
and R
is not that easy.
We're handling "r + anychar" as a single action, so we don't control how the cursor looks "after r
but before anychar
:
export class ActionReplaceCharacter extends BaseCommand {
modes = [Mode.Normal];
keys = ['r', '<character>'];
...
We could have something like a transient mode, and one hand do:
@RegisterAction
export class CommandReplaceAtCursorFromNormalMode extends BaseCommand {
modes = [Mode.Normal];
keys = ['r'];
public override async exec(position: Position, vimState: VimState): Promise<void> {
await vimState.setCurrentMode(Mode.OneCharReplace);
}
}
... and then ...
@RegisterAction
export class ActionReplaceCharacter extends BaseCommand {
modes = [Mode.OneCharReplace];
keys = ['<character>'];
override createsUndoPoint = true;
override runsOnceForEachCountPrefix = false;
public override async exec(position: Position, vimState: VimState): Promise<void> {
const toReplace = this.keysPressed[0];
...
BUT
vimState.recordedState.count
before the r
in ActionReplaceCharacter
r
can be hit also in visual mode and in visualblock modeThanks for all anyway! Hope this can be achievable.
Steps to reproduce: 1) Enter "r" when in normal mode, and work in replace mode. 2) Enter "shift + r" when u come back to normal mode for contrast.
Screenshots:
When I press "r", it functions properly but fails to change the cursor and it doesn't prompt --REPLACE-- at the bottom. (As you can see above)^
========================================================================
On the other hand "Shift + r" (batch replace) works as expected. (As you can see above)^