Ctrl-k (kill to end of line) does not delete empty line. #8575

gwk opened this Issue Jun 30, 2016 · 17 comments


None yet

9 participants

gwk commented Jun 30, 2016

VSCode Version:
Version 1.3.0-insider (1.3.0-insider)

OS Version:
OSX 10.11.5 (15F34)

Steps to Reproduce:

  1. In a new document, type 'a' and then return for a newline.
  2. Place the editor caret in front of 'a'.
  3. Press ctrl-k twice.

In any standard OSX text area, this results in the text 'a' being killed, then the second kill deletes the empty line.
In VS Code, the 'a' gets killed, but the second kill has no effect.

As a user habituated to the standard text commands, this is very annoying, because it prevents me from quickly deleting multiple lines of text; instead, I have to alternate between ctrl-k and ctrl-d.


fyi @joaomoreno

@gwk We bind ctrl+k on the mac to deleteAllRight.


registerCoreCommand(H.DeleteAllRight, {
    primary: null,
    mac: { primary: KeyMod.WinCtrl | KeyCode.KEY_K, secondary: [KeyMod.CtrlCmd | KeyCode.Delete] }

That was my understanding of ctrl+k from https://support.apple.com/en-gb/HT201236


Should ctrl+k bind by default to editor.action.deleteLines or should it handle differently the empty line case in its implementation?

@alexandrudima alexandrudima added this to the Backlog milestone Jul 12, 2016
@alexandrudima alexandrudima added the mac label Jul 12, 2016
gwk commented Jul 12, 2016

@alexandrudima the support article you mention does not describe the 'empty line' case, but it is real, and I hope vscode will support it. Should editor.action.deleteLines handle this case, or do we need a new action?

I tried to find more reference material but it is not very interesting. The system default cocoa keybinding is found in /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict:

"^k": "deleteToEndOfParagraph:"

This name refers to the NSResponder method documented here:


The actual implementation is by NSTextView, NSTextField and whoever else, and I don't see a specification of implemented behavior.

joaomoreno commented Jul 12, 2016 edited

After testing it in three other apps (Sublime, TextEdit, Notes), this is the behaviour I distilled:

  • If the cursor is not at the end of a line, delete everything from that position until the end of the line. This is what we currently have.
  • Otherwise, delete the new line character right after the cursor, effectively joining the current line with the next line.

@alexandrudima Should we implement a context for it (cursorAtEndOfLine) or should we just create a new command SpecialDeleteAllRight?

gwk commented Jul 12, 2016

Agree with @joaomoreno, the behavior is dependent on cursor position, not line contents as I implied earlier! For what it's worth, I think the determination should be made based on the behavior of (default) cocoa text fields, and not Sublime Text, which is a completely custom implementation.


I would go for changing the implementation of DeleteAllRight. I am pretty sure the only reason we added it was for mac's ctrl+k.

jjinux commented Oct 6, 2016

I stumbled across this today. I miss this behavior of ctrl-k since it works almost everywhere in Mac.

francisl commented Dec 1, 2016

This is the normal emacs (not only Mac) keybinding that also work in the terminal and any linux DE with emacs keybinding.


Would love to see this fixed/changed - I have so much muscle memory around Ctrl-K working as described by @joaomoreno above.


I can take this, @alexandrudima. 👍

@joaomoreno joaomoreno modified the milestone: January 2017, Backlog Dec 12, 2016

@joaomoreno I've just moved the code to a better place, outside the editor core (lineOperations.ts)

jjinux commented Dec 12, 2016


nox commented Jan 2, 2017

Did that land in 1.8.1 yet?




Can this be done for DeleteAllLeft as well?


What's the keybinding for that?


@joaomoreno it's cmd+backspace on mac (I imagine cmd+del on Windows)


Yeah, wanna file an issue for it? You can ping me there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment