Reputation: 14664
I'm using VS Code, on a Mac, using the Vim emulation.
If I have a .py
file like this:
test1 = 1
test2 = 2
And I select all three lines, then press <cmd>
and /
I get this:
# test1 = 1
# test2 = 2
I would like the same functionality using a vim command sequence of <leader>
, then c
, then <space>
.
In my settings.json
I have this:
{
"vim.leader": ",",
"vim.normalModeKeyBindings": [
{
"before": ["<leader>", "c", "<space>"],
"commands": ["editor.action.commentLine"],
"when": "editorTextFocus && !editorReadonly"
}
]
}
But, using that sequence, while I can select a single line to toggle commenting on/off, it does nothing when I have multiple lines selected. Why?
Upvotes: 4
Views: 9889
Reputation: 71
Please try adding the following to your settings.json and let me know if it works for you. It worked for me.
"vim.visualModeKeyBindings": [
{
"before": ["<leader>", "c"],
"commands": ["editor.action.commentLine"],
"when": "editorTextFocus && !editorReadonly"
}
],
Upvotes: 7