> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/sxyazi/yazi/llms.txt
> Use this file to discover all available pages before exploring further.

# Tabs

> Creating, switching, and managing tabs in Yazi

Yazi supports multiple tabs, allowing you to work in different directories simultaneously.

## Creating Tabs

### Create New Tab

```bash theme={null}
tt  # Create a new tab in the current working directory
```

The new tab:

* Opens in the same directory as the current tab
* Becomes the active tab immediately
* Has its own independent navigation history

<Note>
  Each tab maintains its own state including:

  * Current directory
  * Directory history
  * Selection state
  * Preview state
</Note>

## Switching Tabs

Yazi provides multiple ways to switch between tabs:

### Direct Tab Switching

Jump directly to a specific tab by number:

| Key | Command        | Description       |
| --- | -------------- | ----------------- |
| `1` | `tab_switch 0` | Switch to 1st tab |
| `2` | `tab_switch 1` | Switch to 2nd tab |
| `3` | `tab_switch 2` | Switch to 3rd tab |
| `4` | `tab_switch 3` | Switch to 4th tab |
| `5` | `tab_switch 4` | Switch to 5th tab |
| `6` | `tab_switch 5` | Switch to 6th tab |
| `7` | `tab_switch 6` | Switch to 7th tab |
| `8` | `tab_switch 7` | Switch to 8th tab |
| `9` | `tab_switch 8` | Switch to 9th tab |

<Tabs>
  <Tab title="Number Keys">
    Quick access to the first 9 tabs using number keys `1-9`.

    ```bash theme={null}
    2  # Jump to second tab
    5  # Jump to fifth tab
    ```
  </Tab>

  <Tab title="Sequential Switching">
    Navigate tabs sequentially using bracket keys.

    | Key | Command                    | Description            |
    | --- | -------------------------- | ---------------------- |
    | `[` | `tab_switch -1 --relative` | Switch to previous tab |
    | `]` | `tab_switch 1 --relative`  | Switch to next tab     |

    ```bash theme={null}
    ]  # Next tab
    [  # Previous tab
    ```
  </Tab>
</Tabs>

### Relative Tab Navigation

```bash theme={null}
[  # Switch to previous tab (wraps around)
]  # Switch to next tab (wraps around)
```

Relative navigation wraps around:

* Pressing `[` on the first tab switches to the last tab
* Pressing `]` on the last tab switches to the first tab

## Reordering Tabs

Swap the current tab with adjacent tabs:

| Key | Command       | Description                        |
| --- | ------------- | ---------------------------------- |
| `{` | `tab_swap -1` | Swap current tab with previous tab |
| `}` | `tab_swap 1`  | Swap current tab with next tab     |

**Example workflow:**

```bash theme={null}
# Move current tab to the left
{  # Swap with previous tab
{  # Swap again

# Move current tab to the right
}  # Swap with next tab
```

<Note>
  Tab swapping changes the order of tabs but doesn't change which tab is active.
</Note>

## Renaming Tabs

```bash theme={null}
tr  # Rename current tab interactively
```

The `tab_rename --interactive` command:

* Opens an input prompt
* Shows the current tab name (if any)
* Allows you to set a custom name for the tab

**Use cases for tab names:**

* Project identification: "frontend", "backend", "docs"
* Task tracking: "review", "testing", "cleanup"
* Location markers: "home", "config", "downloads"

## Closing Tabs

```bash theme={null}
<C-c>  # Close current tab (or quit if it's the last tab)
```

Behavior:

* If multiple tabs are open: Closes the current tab
* If only one tab remains: Quits Yazi
* The previous tab becomes active after closing

<Warning>
  Closing a tab discards its state including:

  * Navigation history
  * Selection state
  * Unsaved filter/search

  Make sure to complete operations before closing a tab.
</Warning>

## Tab State Management

Each tab in Yazi maintains independent state:

### What's Independent Per Tab

* **Current directory**: Each tab can be in a different location
* **Directory history**: Back/forward history is per-tab
* **File selection**: Selected files are tab-specific
* **Preview state**: Preview content is independent
* **Search/filter**: Active searches don't affect other tabs

### What's Shared Across Tabs

* **Yank buffer**: Yanked/cut files are global
* **Configuration**: Settings apply to all tabs
* **Tasks**: Background tasks are shared

<Note>
  The yank buffer being shared across tabs is a powerful feature - you can yank files in one tab and paste them in another.
</Note>

## Practical Tab Workflows

### Workflow 1: Multi-Location File Management

```bash theme={null}
# Tab 1: Source directory
cd ~/projects/old-project
y    # Yank files

# Create new tab for destination
tt
cd ~/projects/new-project
p    # Paste files

# Tab 2 still has the source directory open
[    # Go back to review
```

### Workflow 2: Organized Project Work

```bash theme={null}
# Set up tabs for a project
1    # Tab 1: project root
cd ~/projects/myapp
tr → "root"

tt   # Tab 2: source code
cd src/
tr → "src"

tt   # Tab 3: documentation
cd docs/
tr → "docs"

# Quick navigation
1    # Jump to project root
2    # Jump to source
3    # Jump to docs
```

### Workflow 3: Comparing Directories

```bash theme={null}
# Open two related directories
cd /path/to/version1

tt
cd /path/to/version2

# Switch between them
[    # version1
]    # version2
```

## Tab Indicator

Yazi displays tab information in the UI:

* Current tab is highlighted
* Tab count is visible
* Custom tab names are displayed (if set)
* Active tab indicator

## Implementation Details

Tab management is implemented in `/home/daytona/workspace/source/yazi-core/src/mgr/tabs.rs:9`. The `Tabs` struct maintains:

```rust theme={null}
pub struct Tabs {
    pub cursor: usize,      // Active tab index
    pub items: Vec<Tab>,    // All tab instances
}
```

Each tab is independent with its own:

* Current folder state
* Parent folder reference
* Preview state
* History backstack
* Mode (normal/visual)

## Tips

<Tabs>
  <Tab title="Performance">
    * Yazi tabs are lightweight
    * No performance penalty for having many tabs
    * Each tab's preview is loaded on-demand
  </Tab>

  <Tab title="Workflow">
    * Use numbered tabs (1-9) for frequently accessed locations
    * Name tabs for clarity in complex projects
    * Use tab swapping to organize tabs by priority
  </Tab>

  <Tab title="Integration">
    * Yank buffer works across tabs
    * Shell commands run in the current tab's directory
    * Each tab can have different sort orders and filters
  </Tab>
</Tabs>
