diff --git a/internal/action/actions.go b/internal/action/actions.go index 05ef4e1e..7e3d452a 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -1723,7 +1723,8 @@ func (h *BufPane) ToggleHelp() bool { if h.Buf.Type == buffer.BTHelp { h.Quit() } else { - h.openHelp("help", true, false) + hsplit := config.GlobalSettings["helpsplit"] == "hsplit" + h.openHelp("help", hsplit, false) } return true } diff --git a/internal/action/command.go b/internal/action/command.go index cd8c81a1..13d9f1b2 100644 --- a/internal/action/command.go +++ b/internal/action/command.go @@ -450,12 +450,12 @@ func (h *BufPane) openHelp(page string, hsplit bool, forceSplit bool) error { // HelpCmd tries to open the given help page in a horizontal split func (h *BufPane) HelpCmd(args []string) { + hsplit := config.GlobalSettings["helpsplit"] == "hsplit" if len(args) < 1 { // Open the default help if the user just typed "> help" - h.openHelp("help", true, false) + h.openHelp("help", hsplit, false) } else { var topics []string - hsplit := true forceSplit := false const errSplit = "hsplit and vsplit are not allowed at the same time" for _, arg := range args { diff --git a/internal/config/settings.go b/internal/config/settings.go index b8cfcd51..910a3072 100644 --- a/internal/config/settings.go +++ b/internal/config/settings.go @@ -29,6 +29,7 @@ var optionValidators = map[string]optionValidator{ "detectlimit": validateNonNegativeValue, "encoding": validateEncoding, "fileformat": validateChoice, + "helpsplit": validateChoice, "matchbracestyle": validateChoice, "multiopen": validateChoice, "reload": validateChoice, @@ -41,6 +42,7 @@ var optionValidators = map[string]optionValidator{ var OptionChoices = map[string][]string{ "clipboard": {"internal", "external", "terminal"}, "fileformat": {"unix", "dos"}, + "helpsplit": {"hsplit", "vsplit"}, "matchbracestyle": {"underline", "highlight"}, "multiopen": {"tab", "hsplit", "vsplit"}, "reload": {"prompt", "auto", "disabled"}, @@ -109,6 +111,7 @@ var DefaultGlobalOnlySettings = map[string]interface{}{ "divchars": "|-", "divreverse": true, "fakecursor": false, + "helpsplit": "hsplit", "infobar": true, "keymenu": false, "mouse": true, diff --git a/runtime/help/commands.md b/runtime/help/commands.md index b1cd98dd..a20c8c39 100644 --- a/runtime/help/commands.md +++ b/runtime/help/commands.md @@ -27,9 +27,11 @@ quotes here but these are not necessary when entering the command in micro. Help topics are stored as `.md` files in the `runtime/help` directory of the source tree, which is embedded in the final binary. The `flags` are optional. - * `-hsplit`: Opens the help topic in a horizontal split (default for initial split) + * `-hsplit`: Opens the help topic in a horizontal split * `-vsplit`: Opens the help topic in a vertical split + The default split type is defined by the global `helpsplit` option. + * `save ['filename']`: saves the current buffer. If the file is provided it will 'save as' the filename. diff --git a/runtime/help/options.md b/runtime/help/options.md index ff781834..0ea3b4ee 100644 --- a/runtime/help/options.md +++ b/runtime/help/options.md @@ -172,6 +172,13 @@ Here are the available options: default value: `unknown`. This will be automatically overridden depending on the file you open. +* `helpsplit`: sets the split type to be used by the `help` command. + Possible values: + * `vsplit`: open help in a vertical split pane + * `hsplit`: open help in a horizontal split pane + + default value: `hsplit` + * `hlsearch`: highlight all instances of the searched text after a successful search. This highlighting can be temporarily turned off via the `UnhighlightSearch` action (triggered by the Esc key by default) or toggled