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) VISUALThis 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 / VimThe 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) VISUALSo 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.txtThen inside Vim, run:
:set mouse?If you see:
mouse=athen 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:
iNow 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=
EOFThen 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.vimThe 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 ClickThis 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
Thanks for this… got me back to old school vi behaviour
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=
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.