Currently Ctrl-K deletes from cursor to the end of line. Ctrl-K must cut into the clipboard.
Is there a "cutToEndOfLine" command in vscode that would could use to override in our keybindings.json? I'm looking into switching to vscode and as silly as it may sound this sort of small thing will keep me away.
Here is what we have today (Windows bindings):
editor.action.deleteLines bound to Ctrl+Shift+K that deletes lines and does not place them in clipboard. For example, one of the reasons I like this one is specifically because it doesn't mess with the clipboard.editor.action.clipboardCutAction bound to Ctrl+X that deletes the selection or the entire current line if there is no selection on the line.@dimdin @dotDeeka You would want another action more similar to the first one that also writes the deleted content to the clipboard?
I cant speak for @dimdin, but that is basically what I'm looking for.
I am on OSX and most Cocoa controls in native apps have a base of keyboard shortcuts that are defaults. Most of these shortcuts are emacs keybindings and since I was an avid emacs user for a long time they are ingrained in my head.
ctrl+k in emacs and in most cocoa controls take everything from the cursor to the end of the line and put it in a kill ring. ctrl+y will then paste it back. These shortcuts even work in the Chrome text box I'm typing in right now.
Yesterday after commenting on this thread I began to look into how to write an extension for vscode to get around this problem.
import * as vscode from "vscode";
export let cutToEndOfLine = function () {
vscode.commands.executeCommand("cursorEndSelect").then(() => {
vscode.commands.executeCommand("editor.action.clipboardCutAction");
});
};
full extension is here https://github.com/dotDeeka/ddcode
This hack seems to work fine.
both features in extension above would be use full
@alexandrudima, please see discussion the of defaults on macOS here, especially the section titled The kill buffer, which discusses the behavior of commands like deleteToEndOfLine or deleteToBeginningOfLine.
The behavior as implemented is incredibly frustrating for someone well-accustomed to the native behavior, in that it deletes rather than copies the rest of the line. (I'm used to apps which aren't using CoreText pushing this into the copy/paste buffer instead of the dedicated kill ring, and that's a perfectly reasonable solution here, to be clear. But it has to copy, not delete!)
This is one of the last remaining pain points I have with VS Code as a daily driver, but it drives me utterly up the wall, as I've been using these keystrokes for most of a decade now. 馃槵
In the meantime, I'll be borrowing that bit from @dotDeeka, but please do play nicely with macOS' default so far as you can.
(Note that though this comes as a complaint, the fact that VS Code is becoming my daily driver is a compliment, and a high one. Keep up the good work.)
To keep the number of issues in our inbox at a manageable level, we're closing issues that have been on the backlog for a long time but haven't gained traction: we look at the number of votes the issue has received and the number of duplicate issues filed. Thank you for your time and understanding.
P.S. If you disagree and feel that this issue is crucial: we're happy to listen and to reconsider.
_:sigh:_ This is one of the only major things that frustrates me about VS Code on a daily basis.
I get limited time and attention, of course, but it'd be really nice if Code actually fully respected Mac platform conventions instead of going halfway on these things. This is just one of a bunch of places where Code continues to get it wrong as a citizen of the Mac (terminal meta key behavior with alt is another).
Thanks for reopening. If there's a good place to contribute on these things (with an eye to generally improved macOS keyboard compatibility!), could you link there from here? That'd be amazing!
Issues are the only thing we have...
Switched back to Atom all because of this.
Aching for this to work
For anyone looking for this functionality I recommend installing macros ext:
https://marketplace.visualstudio.com/items?itemName=l7ssha.macrosRe
And configuring it like that
"macros": {
"cutToTheEnd": [
"cursorEndSelect",
"cut"
]
},
And keybind:
{
"key": "ctrl+k",
"command": "macros.cutToTheEnd"
},
It does exactly what this issue's about
@wende Thanks for the suggestion. However, on Mac there is a bug: cutToTheEnd does not seem to save the "cut" text into the clipboard (so I can't later paste it). I also tried adding a delay between "cursorEndSelect" and "cut" but that does not help.
@kbarros Replacing "cut" with "editor.action.clipboardCutAction" does the trick on my Mac:
"macros": {
"cutToTheEnd": [
"cursorEndSelect",
"editor.action.clipboardCutAction"
]
},
I use clipring instead so I didn't notice that. MacOs as well
To add on to the complication, it should really use a buffer-local kill ring, not the system clipboard, so you can kill and then yank without overwriting the clipboard.
I am also frustrated by this issue, wish to see it is fixed.
Most helpful comment
I cant speak for @dimdin, but that is basically what I'm looking for.
I am on OSX and most Cocoa controls in native apps have a base of keyboard shortcuts that are defaults. Most of these shortcuts are emacs keybindings and since I was an avid emacs user for a long time they are ingrained in my head.
ctrl+kin emacs and in most cocoa controls take everything from the cursor to the end of the line and put it in a kill ring.ctrl+ywill then paste it back. These shortcuts even work in the Chrome text box I'm typing in right now.Yesterday after commenting on this thread I began to look into how to write an extension for vscode to get around this problem.
full extension is here https://github.com/dotDeeka/ddcode
This hack seems to work fine.