Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vimrc not accepting mouse-=a command

Tags:

vim

I have strange problem with my /etc/vim/vimrc file.

I was trying to get rid of VISUAL mode in VIM, so I have tried to add the set mouse-=a command in my vimrc file.

However my vim does not take those changes into account.

When I do :set mouse-=a in openend vim, it does what I want (selecting text with mouse without entering VISUAL mode), but the command does not work in the vimrc file.

I have also enabled the "jump to the last position when reopening a file" in vimrc and it is working, that makes me even more confused. I have been trying every possible command:

  • set mouse=a
  • set mouse=r
  • set mouse-=a
  • :set mouse-=a

None of them is working when added to /etc/vim/vimrc.

My system is:

rRr-kali:~# uname -a
Linux rRr-kali 4.8.0-kali2-amd64 #1 SMP Debian 4.8.15-1kali1 (2016-12-23) x86_64 GNU/Linux
rRr-kali:~#
like image 901
rRr Avatar asked Jun 06 '17 11:06

rRr


People also ask

How do I get my mouse to work in Vim?

Mouse reporting is enabled in an app, such as Vim, that runs in a Terminal window. In general, mouse reporting is not enabled in apps by default. For example, to enable mouse reporting in Vim, you need to add a set mouse=a command to your ~/. vimrc file.

How do I enable vimrc?

All you have to do is to create a . vimrc file in the HOME directory of the user than you want to configure Vim for and add the required Vim configuration options there. For simplicity, I will refer to both system wide Vim configuration file and user specific Vim configuration file as vimrc file.

How do I copy and paste with mouse in Vim?

You can copy a block of text by pressing Ctrl-v (or Ctrl-q if you use Ctrl-v for paste), then moving the cursor to select, and pressing y to yank. Now you can move elsewhere and press p to paste the text after the cursor (or P to paste before).

What should be in my vimrc file?

vimrc file can contain variables, conditional code, function definitions etc, but when getting started you will mostly want to stick with enabling/disabling settings and mapping keys. While I have only been working with Vim for a couple of weeks now, I am starting to settle on my favorite settings and key mappings.


2 Answers

If you are using Debian 9 (Strecth), edit the file /usr/share/vim/vim80/defaults.vim and change the line 70 to put

set mouse-=a

Best Regards

Thibault

like image 138
Thibault Richard Avatar answered Oct 07 '22 03:10

Thibault Richard


I know, that this question is a bit old, but I just want to clarify, why both answers above are correct and why it's working that way.

On Debian systems the way the config files for vim are loaded is like this:

  1. Load settings in /etc/vim/vimrc
  2. If exists, load settings from /etc/vim/vimrc.local
  3. If ~/.vimrc does not exist and there is no "let g:skip_defaults_vim = 1" in /etc/vim/vimrc or /etc/vim/vimrc.local, load settings from /usr/share/vim/vim80/defaults.vim otherwise load settings from ~/.vimrc (if it exists).

Details for that can be found in the config files itself, as well as in a discussion on bugs.debian.org

So to solve your issue you have two ways to go:

  1. Insert "let g:skip_defaults_vim = 1" at the beginning of /etc/vim/vimrc.local.
  2. Create an empty ~/.vimrc by issuing touch ~/.vimrc.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=864074

like image 41
Thomas M. Avatar answered Oct 07 '22 03:10

Thomas M.