# Terminal text editors with mouse support

> Which terminal editors support the mouse, and how to turn it on - Vim, Neovim, nano, Micro, Helix, Emacs and Skink - plus why mouse fails in tmux or over SSH.

Source: https://skink.cc/articles/terminal-editor-with-mouse-support/

Most terminal editors support the mouse; the difference is whether it is on by default and how much it does. Micro, Helix, Neovim and Skink turn it on out of the box. Vim needs `set mouse=a`, nano needs `set mouse` (or `nano -m`), and Emacs in a terminal needs `xterm-mouse-mode`.

Terminal mouse support works through escape sequences, so it also works over SSH and inside tmux once tmux allows it.

## How does the mouse work in a terminal?

The editor asks the terminal to report mouse events (with an escape sequence). The terminal then sends clicks, drags and wheel movements as input, like keystrokes.

Modern terminals use the SGR encoding, which has no column limit. Because it is just input, it travels over SSH unchanged.

While an app has the mouse, your terminal's own text selection is off. Most terminals let you hold a modifier (usually Shift) to select with the terminal instead.

## Mouse support, editor by editor

| Editor | Mouse by default | Turn it on | What you can do |
|---|---|---|---|
| Vim | Only via `defaults.vim` (skipped once you have a vimrc) | `set mouse=a`, `set ttymouse=sgr` | Click, drag to Visual select, wheel, resize splits |
| Neovim | Yes (`mouse=nvi`) | `vim.opt.mouse = "a"` | Same as Vim, plus a right-click menu |
| nano | No | `set mouse` in `~/.nanorc`, or `nano -m` | Click to place cursor, double-click sets the mark, wheel scrolls, click shortcuts |
| Micro | Yes | `"mouse": true` | Click, drag, double and triple click, wheel, tabs and splits |
| Helix | Yes | `mouse = true` under `[editor]` | Click, drag select, wheel |
| Emacs (`-nw`) | No | `(xterm-mouse-mode 1)` | Click, drag, wheel, menus |
| Skink | Yes | Nothing to set | See below |

## Config snippets to turn the mouse on

```vim
" Vim: ~/.vimrc
set mouse=a
set ttymouse=sgr
```

```lua
-- Neovim: init.lua (already on for n, v, i)
vim.opt.mouse = "a"
```

```sh
# nano: ~/.nanorc
set mouse
```

```toml
# Helix: ~/.config/helix/config.toml
[editor]
mouse = true
```

## Why doesn't the mouse work in my terminal editor?

- **tmux** catches mouse events for itself. Add `set -g mouse on` to `~/.tmux.conf` so it forwards them to the program in the pane.
- **Over SSH**, the remote editor uses the *remote* config. Your local vimrc or nanorc is not there.
- **Wide windows**: clicks beyond column 223 need the SGR encoding (`ttymouse=sgr` in Vim).
- **Old or odd `TERM`**: set it to `xterm-256color` (or `tmux-256color` inside tmux).
- **Build features**: run `:version` in Vim and look for `+mouse`.

For Vim and Neovim in depth: [how to use mouse clicks in Vim and Neovim](https://skink.cc/articles/how-to-use-the-mouse-in-vim/).

## What Skink does with the mouse

Skink is modeless, so a click never lands you in the wrong mode. It always captures the mouse and uses it for more than cursor placement.

### In the text

- Click places the cursor, drag selects, typing replaces the selection.
- Alt+click adds or removes a cursor.
- The wheel scrolls lines. Shift+wheel or a horizontal trackpad swipe scrolls long lines sideways while the line numbers stay put.

### Around the text

- **Tabs:** click to switch, click the `x` or middle-click to close.
- **Split panes:** click to focus, drag the divider or a pane's title row to resize.
- **File tree:** click or scroll to use it; drag its right border to make it wider or narrower.
- **Gutter:** click a git change mark to peek at it (stage, unstage, revert); click a fold mark to open the fold.
- **Sticky scroll:** click a header to jump to that block.
- **Merge conflicts:** click "Accept ours | theirs | both".

### In terminal tabs

- Programs inside (htop, lazygit, an AI CLI) get mouse events too.
- Ctrl+click a `file:line[:col]` to open it in the editor.

All of this works over SSH and in tmux. Copying with Ctrl+C also reaches your local clipboard through OSC 52.

**Tip:**
To select text with your terminal instead of Skink (for example to copy from the status line), hold your terminal's bypass modifier, usually Shift, while dragging.

## Try it

```sh
curl -fsSL https://skink.cc/install.sh | sh
skink .
```

Details: [mouse and trackpad guide](https://skink.cc/editing/mouse-and-trackpad/). Comparisons: [Skink vs nano](https://skink.cc/compare/nano/), [Skink vs Micro](https://skink.cc/compare/micro/), [Skink vs Helix](https://skink.cc/compare/helix/).
