Fix PuTTY Right-Click Paste Not Working in vi on Ubuntu 26.04

On this page7 sections

This post shows how to fix PuTTY right-click paste in vi on Ubuntu 26.04, where it works on Ubuntu 24.04 but stops pasting in insert mode.

On Ubuntu 26.04, right-clicking in insert mode doesn’t paste the text. Instead, Vim shows something like this at the bottom:

(insert) VISUAL

This problem is usually caused by Vim mouse mode.

Lab context

In this example, I am using:

Client: Windows with PuTTY
Server: Ubuntu 26.04
Editor: vi / Vim

The same PuTTY paste behavior worked on my Ubuntu 24.04 server, but not on Ubuntu 26.04.

Why it happens

On Ubuntu, the vi command usually opens Vim.

Vim has a mouse mode setting. When mouse mode is enabled, Vim receives mouse events directly from the terminal. This means that PuTTY no longer handles the right mouse button as a normal paste action.

Instead of pasting text, Vim interprets the right-click as a mouse operation. That’s why it may enter Visual mode and show:

(insert) VISUAL

So the problem isn’t really PuTTY itself. It’s caused by Vim handling the mouse input.

Check the current Vim mouse setting

Open vi:

vi test.txt

Then inside Vim, run:

:set mouse?

If you see:

mouse=a

then mouse mode is enabled.

Temporary fix

To disable mouse mode only for the current Vim session, run this inside Vim:

:set mouse=

After that, enter insert mode again:

i

Now try pressing the right mouse button in PuTTY. The text should be pasted normally.

This fix only applies to the current Vim session. After closing and reopening Vim, the setting may come back.

Permanent fix

To make the change permanent for the current user, create or update ~/.vimrc.

If you don’t already have a ~/.vimrc, you can create one with:

cat > ~/.vimrc <<'EOF'
runtime defaults.vim
set mouse=
EOF

Then reopen vi.

If you already have a ~/.vimrc, don’t overwrite it. Just add this line to your existing file:

set mouse=

Why use runtime defaults.vim

You may see some guides only adding this line:

set mouse=

That can work, but it isn’t the best option if this is your only Vim customization.

When you create a ~/.vimrc file, Vim may stop automatically loading its default settings file. That default file contains several useful modern Vim defaults, not only mouse settings.

So this version is better:

runtime defaults.vim
set mouse=

The first line keeps Vim’s normal default behavior:

runtime defaults.vim

The second line only disables mouse mode:

set mouse=

This keeps the useful Vim defaults while restoring PuTTY right-click paste behavior.

Alternative paste methods

If you don’t want to change Vim settings, you can still paste in PuTTY using:

Shift + Right Click

This can bypass the mouse handling from the remote terminal application.

If you want right-click paste to behave like it did before, disabling Vim mouse mode is the cleaner fix.

3 thoughts on “Fix PuTTY Right-Click Paste Not Working in vi on Ubuntu 26.04”

  1. Hi! Same here – I’d otherwise want the defaults, though, and want them system-wide + the non-mouse stuff to work, as well. Here’s a proposed fix that works for me:

    (Disable skipping defaults; load defaults; skip loading defaults; overwrite w/ mouse=a)

    in /etc/vim/vimrc.local (Ubuntu 26.04):

    ” Load Ubuntu/Debian defaults now
    unlet! skip_defaults_vim
    source $VIMRUNTIME/defaults.vim

    ” Prevent Vim from auto-loading defaults.vim again later
    let g:skip_defaults_vim = 1

    ” Undo only the mouse setting from defaults.vim
    set mouse=

    1. Yes, that makes sense. My original post was mainly focused on the per-user ~/.vimrc case, where loading defaults.vim first and then disabling mouse mode works for that user.

      For a system-wide setting in /etc/vim/vimrc.local, your approach is better because defaults.vim may otherwise be loaded later and set mouse=a again for users without their own vimrc.

      One small note: the comment lines should use normal Vimscript quotes:

      ” comment

      not curly quotes:

      ” comment

      But the idea is correct. Thanks for sharing the system-wide version.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top