void (@NotNull Editor editor) { SelectionModel selectionModel = editor.getSelectionModel(); if(!selectionModel.hasSelection()) return; int selectionStart = selectionModel.getSelectionStart(); int selectionEnd = selectionModel.getSelectionEnd(); CaretModel caretModel = editor.getCaretModel(); if (editor.isColumnMode() && caretModel.supportsMultipleCarets()) { VisualPosition selectionStartPosition = selectionModel.getSelectionStartPosition(); if (selectionStartPosition != null) { caretModel.moveToVisualPosition(selectionStartPosition); } else { caretModel.moveToOffset(selectionStart); } } else { caretModel.moveToOffset(selectionStart); } selectionModel.removeSelection(); editor.getDocument().deleteString(selectionStart, selectionEnd); scrollToCaret(editor); }