Skip to content

Commit 1ea58a8

Browse files
author
Joshua Kifer
committed
Added proper kill line behavior
1 parent 48ff10e commit 1ea58a8

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

icon.png

4.3 KB
Loading

package.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "nemacs",
33
"displayName": "nemacs",
44
"description": "Minimal emacs keys extension for VSCode with better mark/region support",
5-
"version": "1.0.1",
5+
"version": "1.0.2",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/naturalethic/nemacs.git"
@@ -48,6 +48,10 @@
4848
{
4949
"command": "nemacs.cursorEnd",
5050
"title": "Cursor End"
51+
},
52+
{
53+
"command": "nemacs.killLine",
54+
"title": "Kill Line"
5155
}
5256
],
5357
"keybindings": [
@@ -339,6 +343,11 @@
339343
{ "key": "cmd+;",
340344
"command": "editor.action.commentLine",
341345
"when": "editorTextFocus"
346+
},
347+
{
348+
"key": "ctrl+k",
349+
"command": "nemacs.killLine",
350+
"when": "editorTextFocus"
342351
}
343352
]
344353
},

src/extension.ts

+13
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export function activate(context: ExtensionContext) {
1010
nemacs.cursorMove(cmd)
1111
}))
1212
}
13+
context.subscriptions.push(commands.registerCommand('nemacs.killLine', () => {
14+
nemacs.killLine()
15+
}))
1316
context.subscriptions.push(nemacs)
1417
}
1518

@@ -52,6 +55,16 @@ class Nemacs {
5255
commands.executeCommand('cancelSelection')
5356
}
5457

58+
public killLine() {
59+
let sel = window.activeTextEditor.selection
60+
let line = window.activeTextEditor.document.lineAt(sel.active.line)
61+
if (line.range.end.character == sel.active.character) {
62+
commands.executeCommand('deleteRight')
63+
} else {
64+
commands.executeCommand('deleteAllRight')
65+
}
66+
}
67+
5568
dispose() {
5669
this.disposable.dispose()
5770
}

0 commit comments

Comments
 (0)