diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index a065f075..ce335fa4 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -25,6 +25,7 @@ func InitBindings() { "InsertEnter": InsertEnter, "InsertSpace": InsertSpace, "Backspace": Backspace, + "Delete": Delete, "InsertTab": InsertTab, "Save": Save, "Find": Find, @@ -231,6 +232,7 @@ func DefaultBindings() map[string]string { "CtrlU": "HalfPageUp", "CtrlD": "HalfPageDown", "CtrlR": "ToggleRuler", + "Delete": "Delete", } } @@ -333,6 +335,20 @@ func Backspace(v *View) bool { return true } +// Delete deletes the next character +func Delete(v *View) bool { + if v.cursor.HasSelection() { + v.cursor.DeleteSelection() + v.cursor.ResetSelection() + } else { + loc := v.cursor.Loc() + if loc < len(v.buf.text) { + v.eh.Remove(loc, loc+1) + } + } + return true +} + // InsertTab inserts a tab or spaces func InsertTab(v *View) bool { // Insert a tab