kovidgoyal/kitty · warning

File size %s is too large for performant editing

Error message

File size %s is too large for performant editing

What it means

edit_in_kitty enforces a size cap: if the file exceeds opts.MaxFileSize (interpreted as MiB), it refuses to edit it, reporting the humanized size. This is a deliberate performance guard — loading and editing huge files in the kitty editor would be slow or exhaust memory.

Source

Thrown at tools/cmd/edit_in_kitty/main.go:191

		}
		return 1, &tui.KilledBySignal{Msg: fmt.Sprint("Killed by signal: ", ds), SignalName: ds}
	}
	return
}

func edit_in_kitty(path string, opts *Options) (exit_code int, err error) {
	read_file, err := os.Open(path)
	if err != nil {
		return 1, fmt.Errorf("Failed to open %s for reading with error: %w", path, err)
	}
	defer read_file.Close()
	var s unix.Stat_t
	err = unix.Fstat(int(read_file.Fd()), &s)
	if err != nil {
		return 1, fmt.Errorf("Failed to stat %s with error: %w", path, err)
	}
	if s.Size > int64(opts.MaxFileSize)*1024*1024 {
		return 1, fmt.Errorf("File size %s is too large for performant editing", humanize.Bytes(uint64(s.Size)))
	}

	file_data, err := io.ReadAll(read_file)
	if err != nil {
		return 1, fmt.Errorf("Failed to read from %s with error: %w", path, err)
	}
	read_file.Close()
	data := strings.Builder{}
	data.Grow(len(file_data) * 4)

	add := func(key, val string) {
		if data.Len() > 0 {
			data.WriteString(",")
		}
		data.WriteString(key)
		data.WriteString("=")
		data.WriteString(val)
	}

View on GitHub (pinned to 6d5d0c4406)

Solutions

  1. Edit the file with a tool built for large files (less, vim with lazy loading, sed/awk for targeted changes)
  2. Raise the --max-file-size option if you genuinely need kitty editing and have RAM to spare
  3. Split the file (split, head/tail ranges) and edit the relevant chunk

Example fix

# before
edit-in-kitty huge.log
# after
edit-in-kitty --max-file-size 2048 huge.log   # or: edit only a slice
edit-in-kitty <(sed -n '1,100000p' huge.log)
Defensive patterns

Strategy: validation

Validate before calling

// Check size against the cap before invoking the editor
const maxMiB = 100
if info, err := os.Stat(path); err == nil && info.Size() > maxMiB<<20 {
    fmt.Fprintf(os.Stderr, "%s is %d MiB; cap is %d\n", path, info.Size()>>20, maxMiB)
    os.Exit(1)
}

Prevention

When it happens

Trigger: Opening a file larger than the configured MaxFileSize MiB; opts.MaxFileSize defaults to a modest value, so multi-hundred-MiB logs, data dumps, or datasets trigger it immediately.

Common situations: Trying to edit large log files, CSV/JSON exports, database dumps, or core-dump-adjacent files; or a user lowering MaxFileSize and forgetting files previously editable now trip the limit.

Related errors


AI-assisted analysis of kovidgoyal/kitty@6d5d0c4406 (2026-08-27). Data as JSON: /api/errors/03cdfe55a15938cc. Report an issue: GitHub.