Vim: Please add an option to disable copy while deleting text

Created on 5 Nov 2019  路  10Comments  路  Source: VSCodeVim/Vim

Is your feature request related to a problem? Please describe.

  1. Copy some text from any website.
  2. Enter into vscode, find any file and delete some word in normal or visual mode.
  3. Enter into insert mode and paste text from step 1.
  4. Text from step 1 was overrided by step 2. Then I have to go back to copy it again !

Describe the solution you'd like

  1. add an option to disable copy while deleting text
  2. enable copy when selecting text using mouse.
kinquestion

Most helpful comment

For anyone else landing here from google, these are the settings that work for me (in settings.json):

{
    "vim.useSystemClipboard": true,
    "vim.normalModeKeyBindings": [
        {
            "before": [ "d" ],
            "after": [ "\"", "_", "d" ]
        },
        {
            "before": [ "D" ],
            "after": [ "\"", "_", "D" ]
        },
        {
            "before": [ "d", "d" ],
            "after": [ "\"", "_", "d", "d" ]
        }
    ]
}

All 10 comments

Have you tried mapping d to "_d?

Have you tried mapping d to "_d?
... just don't know what the meaning of d? and how to mapping? or is there any doc?

Add this to you settings.json

{
"before": ["d"],
"after": ["\"", "_", "d"]
}

And you might also want to add one for dd and D.

{
"before": ["D"],
"after": ["\"", "_", "D"]
},
{
"before": ["d", "d"],
"after": ["\"", "_", "d", "d"]
}

d = delete
"_ = Sets the register for the next copy to _ which is not what your clipboard uses. So you will keep whatever is on your clipboard.

@Sheepolution @J-Fields I find new problem: in macvim, there seem to be 2 different clipboards, one for copying manaully, another for vim delete or yank, so command+v and p paste different text; But here I can never do this, the two always paste the same text. If I map d to "_d, the p paste the text from I copying manaully, not I delete. It seems to be a paradox.

@huangyingjie
Let vim use the system clipboard.
"vim.useSystemClipboard": true

@Sheepolution thx a lot, but it had already been true. And Could this feature be default, even these config work perfectly, just image c/C,x/X,s/S, normalMode, visualMode, too many code

@Sheepolution @J-Fields and everyone Trying "vim.useSystemClipboard": false fit my problem. I just want VSCodeVim do exactly the same as vim on mac.

For anyone else landing here from google, these are the settings that work for me (in settings.json):

{
    "vim.useSystemClipboard": true,
    "vim.normalModeKeyBindings": [
        {
            "before": [ "d" ],
            "after": [ "\"", "_", "d" ]
        },
        {
            "before": [ "D" ],
            "after": [ "\"", "_", "D" ]
        },
        {
            "before": [ "d", "d" ],
            "after": [ "\"", "_", "d", "d" ]
        }
    ]
}

@rijkvanzanten Don't know what's different for me, but these settings seem to hang my vscode as soon as a type 'd' and I have to reload the window. It's like they cause an infinite loop in the vim extension.

@konradsa I faced the same issue. Please put the bindings into vim.normalModeKeyBindingsNonRecursive to avoid the VS Code Vim hang.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cckowin picture cckowin  路  3Comments

rajinder-yadav picture rajinder-yadav  路  3Comments

stefanoio picture stefanoio  路  3Comments

typeoneerror picture typeoneerror  路  3Comments

lucastheisen picture lucastheisen  路  3Comments