editor

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 8 Imported by: 13

Documentation

Overview

Package editor provides functionality for opening files in external editors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cmd

func Cmd(app, path string, options ...Option) (*exec.Cmd, error)

Cmd returns a *exec.Cmd editing the given path with $EDITOR or nano if no $EDITOR is set. Deprecated: use Command or CommandContext instead.

func Command added in v0.2.0

func Command(app, path string, options ...Option) (*exec.Cmd, error)

Command returns a *exec.Cmd editing the given path with $EDITOR or nano if no $EDITOR is set.

func CommandContext added in v0.2.0

func CommandContext(ctx context.Context, app, path string, options ...Option) (*exec.Cmd, error)

CommandContext returns a *exec.Cmd editing the given path with $EDITOR or nano if no $EDITOR is set.

Types

type Option

type Option func(editor, filename string) (args []string, pathInArgs bool)

Option defines an editor option.

An Option may act differently in some editors, or not be supported in some of them.

func AtPosition added in v0.2.0

func AtPosition(line, column int) Option

AtPosition opens the file at the given line and column in supported editors. If line or column is less than 1, they will be set to 1. If the editor only supports line numbers, the column will be ignored.

func EndOfLine

func EndOfLine() Option

EndOfLine opens the file at the end of the line in supported editors.

func LineNumber

func LineNumber(number int) Option

LineNumber opens the file at the given line number in supported editors. If [number] is less than line 1, the file will be opened at line 1.

func OpenAtLine deprecated

func OpenAtLine(n int) Option

OpenAtLine opens the file at the given line number in supported editors.

Deprecated: use LineNumber instead.

Jump to

Keyboard shortcuts

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