Replies: 3 comments 3 replies
-
The problem is that you're looking at the register used for the currently executing command, rather than the register that should be used once the command has been completed. When we type But the mapping you provided is evaluated while the command is being built and before it's executed, so the register hasn't been set yet. You'll need to look at You'll notice a TODO comment that wants to remove |
Beta Was this translation helpful? Give feedback.
-
Thanks again for the detailed explanation. I propose renaming the attribute "register" -> {
// The name of the register in effect for the current normal mode
// command (regardless of whether that command actually used a
// register). Or for the currently executing normal mode mapping
// (use this in custom commands that take a register).
// If none is supplied it is the default register '"', unless
// 'clipboard' contains "unnamed" or "unnamedplus", then it is
// "*" or '+' ("unnamedplus" prevails).
val register = KeyHandler.getInstance().keyHandlerState.commandBuilder.registerInEffect
?: when {
injector.globalOptions().clipboard.contains("unnamedplus") -> '+'
injector.globalOptions().clipboard.contains("unnamed") -> '*'
else -> injector.registerGroup.defaultRegister
}
VimString(register.toString())
} I've based this on the documentation (https://neovim.io/doc/user/vvars.html#v%3Aregister) and Vim source code (https://github.com/vim/vim/blob/45e0704d9670c10bfaf2bb408d6a5cd639d23835/src/clipboard.c#L2210). I'm going to look at adding some tests for it and then submit a PR. Let me know if you have any tips about the tests. |
Beta Was this translation helpful? Give feedback.
-
@citizenmatt So I've had to default to Here's the PR: #1046 I also have a few other open PRs if you have a chance to review them. Thanks again for your help! |
Beta Was this translation helpful? Give feedback.
-
In Vim (and IdeaVim), if you select some text then yank it, your cursor moves to the start of the selection after yanking. To change this behavior and keep the cursor in the original position, I've got this key map, which works in Vim:
For example in Vim, if you do
V2j"ay
, then it stores the selected text in thea
register and keeps your cursor in the original position.This doesn't work in IdeaVim because the
v:register
variable isn't implemented yet.So I tried to implement it in
VimVariableServiceBase.getVimVariable()
:However, here
registerChar
doesn't contain the register set by the command. I also tried withinjector.registerGroup.lastRegisterChar
.Can you tell what I might be missing?
Beta Was this translation helpful? Give feedback.
All reactions