I used to have the following in my .vimrc:
" Redirect all delete-operations to black-hole
" Use 'm' ("move") for all cut-operations
nnoremap d "_d
nnoremap m d
What would be the VSCodeVim equivalent? I can't seem to make it work, I already tried the following:
"vim.otherModesKeyBindings": [
{ "before": ["d"], "after": ["\"", "_", "d"] }
],
"vim.otherModesKeyBindingsNonRecursive": [
{ "before": ["m"], "after": ["d"] },
{ "before": ["m", "m"], "after": ["d", "d"] }
]
This makes the bindings for m work, but breaks d...
Your mapping seems to work for me, did you restart vscode after adding the mapping?
Hm that's weird. Yes I did reload (also tried restart) vscode. I have removed everything from my config except the described mapping. Having even just the mapping for d:
"vim.otherModesKeyBindings": [
{ "before": ["d"], "after": ["\"", "_", "d"] }
],
will break d for me completely (it turns聽dd into a no-op for example, when it should make it delete to black-hole).
I've already tried disabling all other mappings & settings, but the issue persists, on two different machines.
Hm, I just noticed that SOME things (like dw) seem to work as expected. However, dd remains broken. Also adding an explicit mapping for dd doesn't help.
Ah yes, I was testing with dw, and not dd
Sorry, I cannot figure out any combination to get dd and d to blackhole correctly
I thought that this would be an issue with difference between recursive remaps and not, but putting this under "otherModesKeyBindingsNonRecursive" also doesn't work. Interestingly, after mapping "d" as above, I can't map "dd" to "editor.action.deleteLine" either.
Anyone else figure this out? Unfortunately this is what's keeping me from moving over to this excellent plugin.
Still somewhat stumped on this one. Haven't found a good workaround.
This has been driving me nuts for like a year.
I'm taking a look at this. I have a possible simple fix, but I'll have to do some testing to make sure it works with different mappings as expected in vanilla Vim.
PR is up! I found that our remapper has other issues mentioned in the PR. I don't think any of those are regressions, so I think we can move forward with this solution.
When the PR is merged, the following vscode setting should allow e.g. dd and dw to become "_dd and "_dw, which work correctly now with our remapper.
{
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["d"],
"after": [ "\"", "_", "d" ]
}
]
}
Hey @shawnaxsom. Thank you for jumping on this. I'm one of those rare designers who fell in love with Vim because of how custom i could make it. As primarily a designer this patch was not something I could have contributed myself and it's great to see this plugin being so well maintained.
I just wanted to say thanks. I do some open source work myself and know it can sometimes be rough dealing with issues. Know that your work helps me be more productive in the editor I prefer and I appreciate the contribution.
@snide Thank you for the kind words! Knowing that it helps users like you makes it more than worth the time and effort.
Thank you, thank you, I use the black hole register all the time and have mapped x to be my nuke button. So glad to find this working. I ran into an issue that was the difference in my settings between only having vim.normalModeKeyBindingsNonRecursive and forgetting to also have a map for vim.visualModeKeyBindingsNonRecursive. Wanted to leave this note here for others who might think it doesn't work only because they are doing something with a visual select.
Most helpful comment
PR is up! I found that our remapper has other issues mentioned in the PR. I don't think any of those are regressions, so I think we can move forward with this solution.
When the PR is merged, the following vscode setting should allow e.g.
ddanddwto become"_ddand"_dw, which work correctly now with our remapper.