diff --git a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExKeyBindings.kt b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExKeyBindings.kt index 40e26a9fd..389529428 100644 --- a/src/main/java/com/maddyhome/idea/vim/ui/ex/ExKeyBindings.kt +++ b/src/main/java/com/maddyhome/idea/vim/ui/ex/ExKeyBindings.kt @@ -25,8 +25,6 @@ internal object ExKeyBindings { KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ExEditorKit.EscapeChar), KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_OPEN_BRACKET, KeyEvent.CTRL_DOWN_MASK), ExEditorKit.EscapeChar), - KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.CTRL_DOWN_MASK), ExEditorKit.DeleteToCursor), - // These appear to be non-Vim shortcuts KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_DOWN_MASK), DefaultEditorKit.pasteAction), KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, KeyEvent.SHIFT_DOWN_MASK), DefaultEditorKit.pasteAction), diff --git a/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/DeleteToCaretAction.kt b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/DeleteToCaretAction.kt new file mode 100644 index 000000000..d0474e4bb --- /dev/null +++ b/vim-engine/src/main/kotlin/com/maddyhome/idea/vim/action/ex/DeleteToCaretAction.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2003-2024 The IdeaVim authors + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE.txt file or at + * https://opensource.org/licenses/MIT. + */ + +package com.maddyhome.idea.vim.action.ex + +import com.intellij.vim.annotations.CommandOrMotion +import com.intellij.vim.annotations.Mode +import com.maddyhome.idea.vim.api.ExecutionContext +import com.maddyhome.idea.vim.api.VimEditor +import com.maddyhome.idea.vim.api.injector +import com.maddyhome.idea.vim.command.Command +import com.maddyhome.idea.vim.command.OperatorArguments +import com.maddyhome.idea.vim.handler.VimActionHandler + +@CommandOrMotion(keys = ["<C-U>"], modes = [Mode.CMD_LINE]) +class DeleteToCaretAction : VimActionHandler.SingleExecution() { + override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED + + override fun execute(editor: VimEditor, context: ExecutionContext, cmd: Command, operatorArguments: OperatorArguments): Boolean { + val commandLine = injector.commandLine.getActiveCommandLine() ?: return false + val oldText = commandLine.actualText + val newText = oldText.substring(commandLine.caret.offset) + commandLine.setText(newText) + commandLine.caret.offset = 0 + return true + } +} \ No newline at end of file