Skip to content

Lofanmi/LazSwitchHosts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LazSwitchHosts

LazSwitchHosts

A lightweight hosts management tool built with Lazarus (Free Pascal), providing a graphical interface for quickly switching between different hosts configurations.

中文版 | A native desktop application designed for users who pursue extreme performance and simplicity, serving as an alternative to the local hosts management functionality of SwitchHosts.

🖥️ Windows Screenshots

Windows Screenshot

SwitchHosts uses approximately 308MB of RAM (Working Set).

Windows Memory Usage 1

LazSwitchHosts uses less than 7MB of memory — extremely lightweight.

Windows Memory Usage 2

The built-in Find & Replace dialog supports regular expressions and case-insensitive matching.

Windows Find and Replace

🎯 Core Advantages

  • Tiny footprint: Under 6MB compiled, under 2MB with UPX compression — a single standalone executable with zero dependencies
  • Minimal memory: Less than 7MB at runtime, saving 98% compared to SwitchHosts (~308MB)
  • Instant startup: Native compilation, no framework loading overhead
  • Native experience: LCL native UI, fast and responsive
  • Plugin-based editor: Reusable editor engine architecture supporting Ctrl+D multi-select editing, syntax highlighting, and find & replace

🔍 Features

  • Graphical interface: Cross-platform desktop app based on LCL
  • Quick switching: One-click switching between different hosts configurations
  • Configuration management: Add, edit, delete, and drag-to-reorder hosts entries
  • Syntax highlighting: Color-coded IP addresses, hostnames, and comments
  • Multi-select editing: Ctrl+D to select matching words one by one for synchronized replacement
  • Find & replace: Supports regular expressions and case-insensitive matching
  • Line operations: Ctrl+C/X/V copies/cuts/pastes entire lines when no selection is active
  • Keyboard shortcuts: Ctrl+S to save, Ctrl+/ to toggle comment, Ctrl+Z/Y for undo/redo
  • System tray: Minimize to tray, double-click to restore

Environment Requirements

  • Supported platforms: Windows, Linux, macOS
  • Development environment: Lazarus IDE
  • Dependencies: BGRABitmapPack (install via Lazarus Online Package Manager)

Environment Variables

  • LAZ_SWITCHHOSTSDIR: Custom configuration directory (default: ~/.SwitchHosts)
  • LAZ_HOSTSFILENAME: Custom hosts file path (default: system hosts file path)

Project Structure

LazSwitchHosts/
├── lazswitchhosts.lpr              # Program entry point
├── unitmain.pas                    # Main window UI and assembly
├── uniteditorengine.pas            # Editor engine core
├── uniteditorplugin.pas            # Editor plugin base class
├── uniteditorkeymap.pas            # Declarative keymap registry
├── uniteditorsyntax.pas            # Syntax provider (hosts, etc.)
├── unitmultiselect.pas             # Multi-select plugin (Ctrl+D)
├── unithostshighlighter.pas        # Hosts syntax highlighter
├── unitsearchdialog.pas            # Find & replace dialog
├── unitconfigmanager.pas           # Configuration manager (JSON)
├── unitutils.pas                   # Platform utility functions
└── unittoggleswitch.pas            # Toggle switch control

Feature Limitations

This project follows a minimalist design philosophy and is not a full replacement for SwitchHosts. The following features are not supported:

  • Remote hosts configuration (URL-based)
  • Sub-folder configuration management
  • Proxy settings
  • Configuration change history backup

Credits

License

This project is licensed under the Apache License 2.0 — see the LICENSE file for details.

About

A lightweight hosts management tool built with Lazarus (Free Pascal). Features syntax highlighting, find & replace with regex, multi-select editing, and a plugin-based editor engine. Less than 7MB memory usage — 98% less than SwitchHosts. Apache-2.0 licensed, cross-platform (Windows/Linux/macOS).

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages