File editors often load the whole file into memory to display it. This approach does not work well with large text files, especially when your RAM is limited. This terminal-based file viewer lets you view large text files (up to 4GB) using O(1) memory. The file viewer also supports efficient text searching (O(pattern length + number of occurrences) memory).
After building the project, head to your terminal and run
${executable} ${file_path}
The file path can be relative or absolute.
The file viewer has two modes: view mode (default) and command mode. To turn on command mode, type "/". To go back to view mode, press Escape.
In view mode, you scroll up and down the document around your current position.
Once you are in command mode, you can enter the following commands
/jump ${position} # Jumps to a position (in bytes from the start of the file)
/search ${pattern} -f ${from} -t ${to} # Launch a search in the background for ${pattern} from ${from} to ${to}. The last two parameters are optional and default to the file's beginning and end.
/cancel # Cancel the current search in the background if there is one.
/exit # Exit the file viewer
Note:
- Due to memory limit, the searches are currently limited to
$5*10^6$ first occurrences of the pattern starting from ${from} - To search for the previous/next matches, press Shift+Tab and Tab.
- You can iterate through matches in both modes.