@@ -428,7 +428,7 @@ func (h *BufPane) ReopenCmd(args []string) {
428428 }
429429}
430430
431- func (h * BufPane ) openHelp (page string ) error {
431+ func (h * BufPane ) openHelp (page string , hsplit bool , forceSplit bool ) error {
432432 if data , err := config .FindRuntimeFile (config .RTHelp , page ).Data (); err != nil {
433433 return errors .New (fmt .Sprintf ("Unable to load help text for %s: %v" , page , err ))
434434 } else {
@@ -437,33 +437,74 @@ func (h *BufPane) openHelp(page string) error {
437437 helpBuffer .SetOptionNative ("hltaberrors" , false )
438438 helpBuffer .SetOptionNative ("hltrailingws" , false )
439439
440- if h .Buf .Type == buffer .BTHelp {
440+ if h .Buf .Type == buffer .BTHelp && ! forceSplit {
441441 h .OpenBuffer (helpBuffer )
442- } else {
442+ } else if hsplit {
443443 h .HSplitBuf (helpBuffer )
444+ } else {
445+ h .VSplitBuf (helpBuffer )
444446 }
445447 }
446448 return nil
447449}
448450
449- // HelpCmd tries to open the given help page in a horizontal split
451+ // HelpCmd tries to open the given help page according to the split type
452+ // configured with the "helpsplit" option. It can be overriden by the optional
453+ // arguments "-vpslit" or "-hsplit". In case more than one help page is given
454+ // as argument then it opens all of them with the defined split type.
450455func (h * BufPane ) HelpCmd (args []string ) {
456+ hsplit := config .GlobalSettings ["helpsplit" ] == "hsplit"
451457 if len (args ) < 1 {
452458 // Open the default help if the user just typed "> help"
453- h .openHelp ("help" )
459+ h .openHelp ("help" , hsplit , false )
454460 } else {
455- if config .FindRuntimeFile (config .RTHelp , args [0 ]) != nil {
456- err := h .openHelp (args [0 ])
457- if err != nil {
458- InfoBar .Error (err )
461+ var topics []string
462+ forceSplit := false
463+ const errSplit = "hsplit and vsplit are not allowed at the same time"
464+ for _ , arg := range args {
465+ switch arg {
466+ case "-vsplit" :
467+ if forceSplit {
468+ InfoBar .Error (errSplit )
469+ return
470+ }
471+ hsplit = false
472+ forceSplit = true
473+ case "-hsplit" :
474+ if forceSplit {
475+ InfoBar .Error (errSplit )
476+ return
477+ }
478+ hsplit = true
479+ forceSplit = true
480+ default :
481+ topics = append (topics , arg )
482+ }
483+ }
484+
485+ if len (topics ) < 1 {
486+ // Do the same as without arg
487+ h .openHelp ("help" , hsplit , forceSplit )
488+ return
489+ }
490+ if len (topics ) > 1 {
491+ forceSplit = true
492+ }
493+
494+ for _ , topic := range topics {
495+ if config .FindRuntimeFile (config .RTHelp , topic ) != nil {
496+ err := h .openHelp (topic , hsplit , forceSplit )
497+ if err != nil {
498+ InfoBar .Error (err )
499+ }
500+ } else {
501+ InfoBar .Error ("Sorry, no help for " , topic )
459502 }
460- } else {
461- InfoBar .Error ("Sorry, no help for " , args [0 ])
462503 }
463504 }
464505}
465506
466- // VSplitCmd opens a vertical split with file given in the first argument
507+ // VSplitCmd opens one or more vertical splits with the files given as arguments
467508// If no file is given, it opens an empty buffer in a new split
468509func (h * BufPane ) VSplitCmd (args []string ) {
469510 if len (args ) == 0 {
@@ -472,16 +513,18 @@ func (h *BufPane) VSplitCmd(args []string) {
472513 return
473514 }
474515
475- buf , err := buffer .NewBufferFromFile (args [0 ], buffer .BTDefault )
476- if err != nil {
477- InfoBar .Error (err )
478- return
479- }
516+ for _ , a := range args {
517+ buf , err := buffer .NewBufferFromFile (a , buffer .BTDefault )
518+ if err != nil {
519+ InfoBar .Error (err )
520+ return
521+ }
480522
481- h .VSplitBuf (buf )
523+ h .VSplitBuf (buf )
524+ }
482525}
483526
484- // HSplitCmd opens a horizontal split with file given in the first argument
527+ // HSplitCmd opens one or more horizontal splits with the files given as arguments
485528// If no file is given, it opens an empty buffer in a new split
486529func (h * BufPane ) HSplitCmd (args []string ) {
487530 if len (args ) == 0 {
@@ -490,21 +533,24 @@ func (h *BufPane) HSplitCmd(args []string) {
490533 return
491534 }
492535
493- buf , err := buffer .NewBufferFromFile (args [0 ], buffer .BTDefault )
494- if err != nil {
495- InfoBar .Error (err )
496- return
497- }
536+ for _ , a := range args {
537+ buf , err := buffer .NewBufferFromFile (a , buffer .BTDefault )
538+ if err != nil {
539+ InfoBar .Error (err )
540+ return
541+ }
498542
499- h .HSplitBuf (buf )
543+ h .HSplitBuf (buf )
544+ }
500545}
501546
502547// EvalCmd evaluates a lua expression
503548func (h * BufPane ) EvalCmd (args []string ) {
504549 InfoBar .Error ("Eval unsupported" )
505550}
506551
507- // NewTabCmd opens the given file in a new tab
552+ // NewTabCmd opens one or more tabs with the files given as arguments
553+ // If no file is given, it opens an empty buffer in a new tab
508554func (h * BufPane ) NewTabCmd (args []string ) {
509555 width , height := screen .Screen .Size ()
510556 iOffset := config .GetInfoBarOffset ()
0 commit comments