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

When I connected to an Ubuntu 24.04 server using PuTTY, I could open vi, enter insert mode, and paste text by pressing the right mouse button.

However, after connecting to an Ubuntu 26.04 server, the same behavior did not work. When I pressed the right mouse button in insert mode, the text was not pasted. Instead, Vim showed something like this at the bottom:

(insert) VISUAL

This problem is usually caused by Vim mouse mode.


Environment

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 This 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 is why it may enter Visual mode and show:

(insert) VISUAL

So the problem is not really PuTTY itself. It is 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 do not 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, do not 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 is not 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 do not 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.

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

Did this guide save you time?

Support this site

Leave a Comment

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

Scroll to Top