Skip to main content

Overview

WezTerm provides powerful search capabilities for finding text in your terminal output and scrollback history. You can search using plain text, case-sensitive matching, or regular expressions. Open the search overlay with an optional pre-filled pattern:
local wezterm = require 'wezterm'
local act = wezterm.action
local config = {}

config.keys = {
  -- Open empty search
  {
    key = 'F',
    mods = 'CTRL|SHIFT',
    action = act.Search 'CurrentSelectionOrEmptyString',
  },
  -- Search for git hashes
  {
    key = 'H',
    mods = 'CTRL|SHIFT',
    action = act.Search { Regex = '[a-f0-9]{6,}' },
  },
}

return config
pattern
Pattern
required
The search pattern to use. Can be one of:
  • 'CurrentSelectionOrEmptyString' - Use selected text or empty (default)
  • { CaseSensitiveString = 'text' } - Exact case-sensitive match
  • { CaseInSensitiveString = 'text' } - Case-insensitive match
  • { Regex = 'pattern' } - Regular expression pattern

Search Pattern Types

CurrentSelectionOrEmptyString

Use the currently selected text as the search term:
config.keys = {
  {
    key = 'f',
    mods = 'CTRL|SHIFT',
    action = act.Search 'CurrentSelectionOrEmptyString',
  },
}
If there’s no selection, the search overlay opens empty, ready for input.

CaseSensitiveString

Search for an exact string match:
config.keys = {
  {
    key = 'e',
    mods = 'CTRL|SHIFT',
    action = act.Search { CaseSensitiveString = 'ERROR' },
  },
}
This will only match “ERROR” exactly, not “error” or “Error”.

CaseInSensitiveString

Search for a string ignoring case:
config.keys = {
  {
    key = 'w',
    mods = 'CTRL|SHIFT',
    action = act.Search { CaseInSensitiveString = 'warning' },
  },
}
This will match “warning”, “WARNING”, “Warning”, etc.

Regex

Search using regular expressions:
config.keys = {
  -- Find git hashes
  {
    key = 'h',
    mods = 'CTRL|SHIFT',
    action = act.Search { Regex = '[a-f0-9]{7,40}' },
  },
  -- Find URLs
  {
    key = 'u',
    mods = 'CTRL|SHIFT',
    action = act.Search { Regex = 'https?://\\S+' },
  },
  -- Find email addresses
  {
    key = 'm',
    mods = 'CTRL|SHIFT',
    action = act.Search { Regex = '[\\w._%+-]+@[\\w.-]+\\.[\\w]{2,}' },
  },
  -- Find IP addresses
  {
    key = 'i',
    mods = 'CTRL|SHIFT',
    action = act.Search { Regex = '\\b(?:[0-9]{1,3}\\.){3}[0-9]{1,3}\\b' },
  },
}
WezTerm uses Rust’s regex syntax. View the full syntax documentation
When in copy mode, you can use search-specific navigation actions:

Copy Mode Search Actions

config.key_tables = {
  copy_mode = {
    -- Open search
    { key = '/', action = act.CopyMode 'EditPattern' },
    
    -- Navigate search results
    { key = 'n', action = act.CopyMode 'NextMatch' },
    { key = 'N', mods = 'SHIFT', action = act.CopyMode 'PriorMatch' },
    
    -- Navigate by pages of matches
    { key = 'PageUp', action = act.CopyMode 'PriorMatchPage' },
    { key = 'PageDown', action = act.CopyMode 'NextMatchPage' },
    
    -- Cycle match type (case sensitive, case insensitive, regex)
    { key = 'r', mods = 'CTRL', action = act.CopyMode 'CycleMatchType' },
    
    -- Clear search pattern
    { key = 'Escape', action = act.CopyMode 'ClearPattern' },
    
    -- Accept and close search
    { key = 'Enter', action = act.CopyMode 'AcceptPattern' },
  },
}
EditPattern
CopyModeAssignment
Open or edit the search pattern
NextMatch
CopyModeAssignment
Jump to the next match
PriorMatch
CopyModeAssignment
Jump to the previous match
NextMatchPage
CopyModeAssignment
Jump forward by a page of matches
PriorMatchPage
CopyModeAssignment
Jump backward by a page of matches
CycleMatchType
CopyModeAssignment
Toggle between case-sensitive, case-insensitive, and regex matching
ClearPattern
CopyModeAssignment
Clear the current search pattern
AcceptPattern
CopyModeAssignment
Accept the current pattern and close the search input

ActivateCopyMode

Enter copy mode, which provides keyboard-driven navigation and search:
config.keys = {
  {
    key = '[',
    mods = 'CTRL|SHIFT',
    action = act.ActivateCopyMode,
  },
}
Copy mode allows you to:
  • Navigate with keyboard (vim-style bindings)
  • Search and navigate results
  • Select and copy text without using the mouse

Complete Example

local wezterm = require 'wezterm'
local act = wezterm.action
local config = {}

config.keys = {
  -- Open search with current selection or empty
  {
    key = 'f',
    mods = 'CTRL|SHIFT',
    action = act.Search 'CurrentSelectionOrEmptyString',
  },
  
  -- Enter copy mode for keyboard navigation
  {
    key = '[',
    mods = 'CTRL|SHIFT',
    action = act.ActivateCopyMode,
  },
}

return config

Search Overlay Controls

When the search overlay is active:
  • Enter - Navigate to next match
  • Shift+Enter - Navigate to previous match
  • Ctrl+R - Cycle match type (case-sensitive → case-insensitive → regex)
  • Ctrl+U - Clear the search input
  • Escape - Close search overlay
  • Up/Down arrows - Navigate match history

Regular Expression Examples

Common regex patterns for searching:
local common_patterns = {
  -- Git commit hashes (7-40 hex chars)
  git_hash = '[a-f0-9]{7,40}',
  
  -- URLs
  url = 'https?://\\S+',
  
  -- Email addresses
  email = '[\\w._%+-]+@[\\w.-]+\\.[\\w]{2,}',
  
  -- IPv4 addresses
  ipv4 = '\\b(?:[0-9]{1,3}\\.){3}[0-9]{1,3}\\b',
  
  -- File paths (Unix)
  unix_path = '(?:/[^/\\s]+)+/?',
  
  -- File paths (Windows)
  windows_path = '[A-Za-z]:\\\\[^\\s]+',
  
  -- UUIDs
  uuid = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',
  
  -- Semantic version numbers
  semver = '\\b\\d+\\.\\d+\\.\\d+\\b',
  
  -- Time stamps (HH:MM:SS)
  time = '\\b\\d{2}:\\d{2}:\\d{2}\\b',
}
Use the CycleMatchType action (Ctrl+R) in the search overlay to quickly switch between case-sensitive, case-insensitive, and regex matching without retyping your pattern