Reputation:
Vim automatic visual mode can be annoying. It's switching into visual mode when ever you left click and select a text in it. Fortunately there is the possibility to bypass this behaviour by holding shift-key while selecting text in the terminal. This bypass is useful, quickly to use at hand without having to configure vim first.
However I recently noticed that, when the terminal detects something as a link (for instance /var/www/example.com/ directory in apache vhost configs), and I try to select it using mouse+shift-key combination, it doesn't let me copy the selected text but jumps to the next similar line in the text while enabling auto visual mode again.
Why does this happen and how can I bypass that?
PS: I know about :set mouse-=a in vimrc but as I am working on different servers I don't want to have to edit vimrc each time I am on a new server.
Upvotes: 0
Views: 1032
Reputation: 1813
Someone is setting mouse=a
. You can find the guilty one by executing :verbose set mouse
.
Then you either have to change that or you have to create a .vimrc for your user. As far as I understand that might not be easy in your situation.
Instead of set mouse-=a
you could also use set mouse=
to disable all mouse stuff. This is what I prefer and it saves two keystrokes :-).
This is how I handle this problem. It might or might not be doable for you.
I have one file called .rks
, that I scp to every server I have to login.
The first command after login is always
. ./.rks
This sets up my shell environment (prompt, aliases, vi editing mode etc) and creates a file
called ~/.vimrc.rks
(if it doesn't exist) containing my basic Vim setup
(e.g. set mouse=
). Finally it exports the variable VIMINIT
:
export VIMINIT="source $HOME/.vimrc.rks"
Now Vim sources ~/.vimrc.rks
on startup and I get my setup.
This way I
.vimrc.rks
) are created when sourcing that file.I just learned, that I could automate the transfer of my setup file using ssh LocalCommand
configuration. See this answer on serverfault.
Upvotes: 0
Reputation: 31060
If there's a specific setting that you want on your main machine, but not on other servers etc then you can use an if
statement in your .vimrc
to specify which system you want the setting to be active on. For instance:
"My Linux machine
if readf('/etc/machine-id') == ['your-machine-id']
set mouse=a
endif
"Only on Macs
if system('uname') == "Darwin\n"
set mouse=a
endif
Upvotes: 0
Reputation: 6026
The only text-selection vim has is visual mode. So you tell vim with mouse=a
that it should use the mouse to select text. What do you expect?
You could always copy the text without your mouse at all ("+yy
if you have clipboard support).
I could not reproduce your behavior with the links. Is this also happening without plugins?
But anyway, if you don't want visual mode on your mouse, you have to modify the mouse
setting and stop telling vim to use visual mode on your mouse.
Upvotes: 1