From de9567322bbb3f47dc43fac7f37df97d4b0197b8 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Tue, 16 Aug 2016 10:55:04 -0400 Subject: [PATCH] Rebind Home and End to StartOfLine and EndOfLine This commit changes the default keybindings for Home and End. It also changes the InsertEnter action to InsertNewline (a better name) although InsertEnter is still valid for backwards compatibility. Closes #206 --- cmd/micro/actions.go | 4 ++-- cmd/micro/bindings.go | 11 +++++++---- runtime/help/help.md | 15 ++++++++------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/cmd/micro/actions.go b/cmd/micro/actions.go index 27165c12..4a171947 100644 --- a/cmd/micro/actions.go +++ b/cmd/micro/actions.go @@ -211,8 +211,8 @@ func (v *View) InsertSpace() bool { return true } -// InsertEnter inserts a newline plus possible some whitespace if autoindent is on -func (v *View) InsertEnter() bool { +// InsertNewline inserts a newline plus possible some whitespace if autoindent is on +func (v *View) InsertNewline() bool { // Insert a newline if v.Cursor.HasSelection() { v.Cursor.DeleteSelection() diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index 1053a962..f9d085cd 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -35,7 +35,7 @@ var bindingActions = map[string]func(*View) bool{ "DeleteWordLeft": (*View).DeleteWordLeft, "SelectToStartOfLine": (*View).SelectToStartOfLine, "SelectToEndOfLine": (*View).SelectToEndOfLine, - "InsertEnter": (*View).InsertEnter, + "InsertNewline": (*View).InsertNewline, "InsertSpace": (*View).InsertSpace, "Backspace": (*View).Backspace, "Delete": (*View).Delete, @@ -76,6 +76,9 @@ var bindingActions = map[string]func(*View) bool{ "NextTab": (*View).NextTab, "NextSplit": (*View).NextSplit, "PreviousSplit": (*View).PreviousSplit, + + // This was changed to InsertNewline but I don't want to break backwards compatibility + "InsertEnter": (*View).InsertNewline, } var bindingKeys = map[string]tcell.Key{ @@ -363,7 +366,7 @@ func DefaultBindings() map[string]string { "CtrlDown": "CursorEnd", "CtrlShiftUp": "SelectToStart", "CtrlShiftDown": "SelectToEnd", - "Enter": "InsertEnter", + "Enter": "InsertNewline", "Space": "InsertSpace", "Backspace": "Backspace", "Backspace2": "Backspace", @@ -387,8 +390,8 @@ func DefaultBindings() map[string]string { "CtrlT": "AddTab", "CtrlRightSq": "PreviousTab", "CtrlBackslash": "NextTab", - "Home": "Start", - "End": "End", + "Home": "StartOfLine", + "End": "EndOfLine", "PageUp": "CursorPageUp", "PageDown": "CursorPageDown", "CtrlG": "ToggleHelp", diff --git a/runtime/help/help.md b/runtime/help/help.md index 41242ef5..1d63ae64 100644 --- a/runtime/help/help.md +++ b/runtime/help/help.md @@ -43,13 +43,14 @@ you can rebind them to your liking. "CtrlDown": "CursorEnd", "CtrlShiftUp": "SelectToStart", "CtrlShiftDown": "SelectToEnd", - "Enter": "InsertEnter", + "Enter": "InsertNewline", "Space": "InsertSpace", "Backspace": "Backspace", "Backspace2": "Backspace", "Alt-Backspace": "DeleteWordLeft", "Alt-Backspace2": "DeleteWordLeft", - "Tab": "InsertTab", + "Tab": "IndentSelection,InsertTab", + "Backtab": "OutdentSelection", "CtrlO": "OpenFile", "CtrlS": "Save", "CtrlF": "Find", @@ -63,11 +64,11 @@ you can rebind them to your liking. "CtrlD": "DuplicateLine", "CtrlV": "Paste", "CtrlA": "SelectAll", - "CtrlT": "AddTab" + "CtrlT": "AddTab", "CtrlRightSq": "PreviousTab", "CtrlBackslash": "NextTab", - "Home": "Start", - "End": "End", + "Home": "StartOfLine", + "End": "EndOfLine", "PageUp": "CursorPageUp", "PageDown": "CursorPageDown", "CtrlG": "ToggleHelp", @@ -79,14 +80,14 @@ you can rebind them to your liking. "CtrlQ": "Quit", "CtrlE": "CommandMode", "CtrlW": "NextSplit", - + // Emacs-style keybindings "Alt-f": "WordRight", "Alt-b": "WordLeft", "Alt-a": "StartOfLine", "Alt-e": "EndOfLine", "Alt-p": "CursorUp", - "Alt-n": "CursorDown" + "Alt-n": "CursorDown", } ```