Overview
The View tool reads files and displays their contents with line numbers. It’s the primary tool for examining files before making edits, understanding code structure, and gathering context.Parameters
The path to the file to read. Can be absolute or relative to the working directory.
The line number to start reading from (0-based). Use this to read specific sections of large files. Defaults to 0.
The maximum number of lines to read. Defaults to 2000 lines. Use with offset to paginate through large files.
Features
Line Numbers
All output includes line numbers in the format:Large File Handling
For files with more than 2000 lines, use theoffset and limit parameters:
File Suggestions
If a file is not found, View will suggest similarly-named files:Image Support
View can display image files directly in the terminal when using models that support vision: Supported formats:- PNG (
.png) - JPEG (
.jpg,.jpeg) - GIF (
.gif) - WebP (
.webp)
Limitations
File Size
- Maximum file size: 5 MB
- Files larger than 5 MB cannot be read
- Use pagination with offset/limit for large text files
Line Length
- Maximum line length: 2000 characters
- Lines longer than 2000 characters are truncated with
...
Default Line Limit
- Default limit: 2000 lines per read
- Skill files (SKILL.md) have no limit
- Use offset to read beyond the first 2000 lines
Binary Files
- Non-text files cannot be displayed (except images)
- Binary file detection is automatic
- Use appropriate tools for binary file inspection
Output Format
View returns output wrapped in<file> tags:
LSP Integration
When viewing code files, Crush automatically:- Opens the file in LSP if a language server is available
- Waits briefly for diagnostics (300ms)
- Includes diagnostics in the output:
Usage Examples
Read Entire File
Read Specific Section
Read Next Section
After reading the first 2000 lines:Best Practices
When to Use View
- Before editing - Always view a file before making changes
- Understanding code - Read files to understand structure and context
- Checking results - View files after edits to verify changes
- Gathering context - Read related files to understand dependencies
Efficient Reading
- Start with Grep or Glob - Find relevant files first
- Use offset/limit - For large files, read specific sections
- Read multiple files in parallel - When gathering context
Reading Large Files
Permissions
Auto-Approved
- Reading files within the working directory
- Reading skill files (SKILL.md)
Requires Permission
- Reading files outside the working directory
Cross-Platform Notes
Line Endings
- Unix/Linux/macOS: LF (
\n) - Windows: CRLF (
\r\n)
Path Separators
Use forward slashes/ for all platforms:
- ✅
C:/Users/name/file.txt - ❌
C:\\Users\\name\\file.txt
src/main.go../config.json
Common Workflows
Edit Workflow
- View the file to understand current state
- Identify the change needed
- Use Edit tool with exact text from View output
- View again to verify changes
Code Understanding
- Use Grep to find relevant files
- View each file to understand implementation
- Follow imports by viewing related files
- Note LSP diagnostics for potential issues
Debugging
- View error logs to see error messages
- View source files to understand the code
- View test files to understand expected behavior
- Check LSP diagnostics for compile errors
Troubleshooting
File Not Found
- Check the path is correct
- Use LS tool to verify directory contents
- Check for typos in filename
- Use absolute paths to avoid ambiguity
File Too Large
- Use offset and limit to read sections
- Consider if you need the entire file
- Use Grep to search for specific content
Binary File Error
- View is for text files only
- Use appropriate tools for binary inspection
- Check file extension matches content
Permission Denied
- File may be outside working directory
- Approve the permission prompt
- Add to allow list if regularly accessed
View vs Other Tools
View vs Bash cat
Use View:- Provides line numbers
- Integrates with LSP
- Handles large files better
- Cross-platform consistent
- Piping to other commands
- When combined with other shell tools
View vs Grep
Use View:- Reading entire files
- Understanding file structure
- Seeing context around code
- Finding specific patterns
- Searching across many files
- When you know what you’re looking for
View vs Editor Tools
Use View:- Reading current state
- Before making edits
- After making edits to verify
- Making changes to files
- Creating new files
- Modifying existing content