NeNe Nib

Large files and encodings

NeNe Nib can open large files such as logs and data. You can open UTF-8 files up to 1 GiB, and you can keep writing in other tabs while a file loads. Besides UTF-8, Nib handles the Shift_JIS and UTF-16 encodings. This chapter explains how to open large files, how files with very long lines are displayed, and how to choose the encoding and line ending.

Nib detects the encoding of a file automatically when you open it. There is no step for choosing an encoding when you open a file. The encoding you choose in the status bar is the encoding used when you save.

Open large files

Open a large file the same way as any other file: with Ctrl+O (Ctrl+Shift+O in Vim mode) or by drag and drop.

File size What happens
Up to 64 MiB The file is loaded and opened right away.
Over 64 MiB, up to 1 GiB (UTF-8) The file is loaded in the background. The status bar shows the progress, such as "Loading: filename 37%", and the tab opens when loading is done. You can keep writing in other tabs in the meantime.
Over 64 MiB (Shift_JIS, UTF-16) The file cannot be opened. Nib shows "Shift_JIS / UTF-16 files larger than 64 MiB cannot be opened."
Over 1 GiB The file cannot be opened. Nib shows "Files larger than 1 GB cannot be opened." (meaning 1 GiB).

MiB and GiB are sizes based on units of 1,024 (1 MiB is 1,024 × 1,024 bytes).

With large files, these operations take time.

Open files with very long lines

Some files have a single line of more than 16,384 characters with no line breaks, such as logs written on one line or JSON with the line breaks removed. When you open such a file, Nib first asks "This file has a very long line with no line breaks. Do you want to open it in grid view?"

Answer What happens
Yes The file opens in grid view. Grid view arranges characters in cells of equal width and uses a monospaced font. Long lines also wrap at the window width. grid appears on the right side of the status bar.
No The file opens in the normal view. Only the long lines are not wrapped, and a mark appears next to their line numbers. Only the area around the caret is laid out and displayed, so even long lines do not slow things down.

Turn word wrap on or off

By default, long lines wrap at the window width. How to turn wrapping off and back on is explained in the Themes and appearance chapter.

Understand encodings

An encoding is the rule for turning characters into the bytes of a file. Nib handles these encodings.

Encoding Shown in the status bar as Description
UTF-8 UTF-8 New documents are saved in this format.
UTF-8 (with BOM) UTF-8 BOM UTF-8 with a BOM (a mark of a few bytes that indicates the encoding) at the start.
Shift_JIS Shift_JIS A Japanese encoding. Nib handles the extended form used in Windows (CP932).
UTF-16 (little-endian) UTF-16 LE A format that represents each character with 2 bytes (or 4 bytes). Little-endian is the byte order that puts the lower byte of the 2 bytes first. Only files with a BOM are supported.
UTF-16 (big-endian) UTF-16 BE The byte order is the reverse of UTF-16 LE: the higher byte comes first. Only files with a BOM are supported.

Check how the encoding is detected

Nib detects the encoding of a file you open in this order.

  1. If the file starts with a UTF-16 BOM, it opens as UTF-16.
  2. If the file starts with a UTF-8 BOM, it opens as UTF-8 (with BOM).
  3. If it can be read as valid UTF-8, it opens as UTF-8.
  4. If it can be read as Shift_JIS, it opens as Shift_JIS.
  5. Otherwise, Nib shows "The encoding could not be detected." and does not open the file.

Change the encoding used for saving

To do this Do this What happens
Choose an encoding Click the encoding (such as UTF-8) on the right side of the status bar You can choose the encoding to save with from a list.
Do the same from All Commands Choose Encoding in All Commands (F1) The same list appears.
Do the same in Vim mode :set fenc=cp932 and so on Choose from utf-8, utf-8-bom, cp932 (Shift_JIS), utf-16le, and utf-16be.

Some characters, such as emoji, cannot be written in Shift_JIS. If you try to save a document that contains such characters in Shift_JIS, Nib asks "Some characters cannot be saved in this encoding. Do you want to save as UTF-8?" Choose Yes to save as UTF-8, or No to cancel saving.

Change line endings

There are two line ending formats: CRLF, the standard on Windows, and LF, the standard on macOS and Linux.

Going further: Compare how fast files open

These are the results of comparing NeNe Nib and Notepad (Notepad 11.2609 on Windows 11) under the same conditions on the developer's PC. The version measured was NeNe Nib 1.1.0, not the current 1.2.0.

Measurement NeNe Nib 1.1.0 Notepad
From start until the text of a 200-line file appears 100 ms 450 ms
From opening a 16 MiB file until its text appears 117 ms 908 ms
Memory after opening a 16 MiB file 30.4 MiB 88.7 MiB

ms means milliseconds (thousandths of a second). For a 16 MiB file, Nib opens it in about one eighth of the time Notepad takes and uses about one third of the memory.

The numbers are the median of 20 runs (10 runs for memory), measured on one PC with a Core i9-10850K, an RTX 3090, and Windows 11, with default settings and the same window size.

Going further: Check size limits and encoding details

With large files, these features have limits.

Feature Limit When the limit is exceeded
Opening (UTF-8, UTF-8 BOM) 1 GiB The file cannot be opened.
Opening (Shift_JIS, UTF-16) 64 MiB The file cannot be opened.
Size at which loading moves to the background Over 64 MiB The status bar shows the progress.
Autosave 64 MiB The document is not autosaved.
Printing 16 MiB Nib shows "Printing is limited to 16 MiB".
Preview in Files and Tabs 16 MiB Nib shows "Too large to preview (up to 16 MiB)".
Line length (asks about grid view) 16,384 characters When you open the file, Nib asks whether to use grid view.

Encodings follow these detailed rules.

Next: Troubleshooting covers common problems and how to fix them.

Source of this manual: nene-nib / docs/manual/en(179fe3be)