Ubuntu won't let me edit or delete .vimrc file

I wanted to add set mouse=a to the .vimrc file to add point and click cursor, but the /etc/vim/vimrc file is read-only and won't allow me to edit or delete it. I tried to uninstall and reinstall vim but the .vimrc file remained unchanged.
Additionally when I try to edit it from terminal using

sudo vim /etc/vim/vimrc

it says

Found a swap file by name of 'filename'

Apparently it says I edited the same file twice.


Solution 1:

User-specific changes like that should go in your personal .vimrc, which should be located in your home directory. If this file doesn’t exist yet you can simply create it. This will add your set line to ~/.vimrc creating this file if necessary:

echo 'set mouse=a' >>~/.vimrc

After that, either restart vim or source the file in a running instance with

:source ~/.vimrc

for the change to take effect.

Solution 2:

When vim gives you this warning, it also should give you some options at the bottom:

[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

Chose "R" if you want to recover whatever changes and "E" if you don't.

If you persistently get this message, delete the swap file named.

More information is found in the error message normally.