editor

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package editor provides utilities for opening files in the user's preferred editor.

Package editor provides utilities for opening files in the user's preferred editor. It supports automatic detection of editors on Windows, macOS, and Linux.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultEditor

func GetDefaultEditor() string

GetDefaultEditor returns the name of the detected default editor. Returns empty string if no editor is found.

func IsEditorAvailable

func IsEditorAvailable(editor string) bool

IsEditorAvailable checks if a specific editor is available on the system.

func Open

func Open(path string) error

Open opens the specified file in the user's preferred editor. Uses EDITOR or VISUAL environment variables if set, otherwise auto-detects.

func OpenWithOptions

func OpenWithOptions(path string, opts OpenOptions) error

OpenWithOptions opens a file with custom options.

Types

type OpenOptions

type OpenOptions struct {
	// Editor overrides the default editor detection.
	// If empty, uses EDITOR, VISUAL env vars, or auto-detects.
	Editor string

	// WaitForClose blocks until the editor process exits.
	// Defaults to true.
	WaitForClose bool

	// LineNumber opens the file at a specific line (if supported by editor).
	LineNumber int
}

OpenOptions configures how to open a file in an editor.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL