tel2
asked on
Linux: disable vim auto-comment
Hi UNIX/Linux experts,
Sometimes I copy and paste code into a text file which I have opened with vim (vi improved). By default, if any line I paste starts with a comment character ("#"), vim will automatically prefix all subsequent lines with a "#". To avoid this from happening, I can type this command before I do the pasting:
:set comments=
Although that works, I would like to have this option set by default. I have tried putting this:
set comments=
into my .vimrc file, but it doesn't seem to make any difference.
Please post tested solutions only.
I'm using vim version 7.4.160 on Linux (GNU).
Thanks.
tel2
Sometimes I copy and paste code into a text file which I have opened with vim (vi improved). By default, if any line I paste starts with a comment character ("#"), vim will automatically prefix all subsequent lines with a "#". To avoid this from happening, I can type this command before I do the pasting:
:set comments=
Although that works, I would like to have this option set by default. I have tried putting this:
set comments=
into my .vimrc file, but it doesn't seem to make any difference.
Please post tested solutions only.
I'm using vim version 7.4.160 on Linux (GNU).
Thanks.
tel2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
...and I just noticed that after adding the command you gave me to .vimrc, and then removing it again, I can't reproduce the problem. Any ideas why? Is it just a one-off which doesn't have to stay in .vimrc? If so, where is the fact that it's been executed remembered?
can you turn it on again by putting +r insted on -r? and then remove from vimrc again? does it stay on?
I'm not sure if it is normal behavior, until now i naver had to change .vimrc for myself as happy with default config on my distro.
Here is the link where i found the command. http://vim.1045645.n5.nabble.com/Turning-off-auto-comment-yes-already-tried-that-td5488277.html
I'm not sure if it is normal behavior, until now i naver had to change .vimrc for myself as happy with default config on my distro.
Here is the link where i found the command. http://vim.1045645.n5.nabble.com/Turning-off-auto-comment-yes-already-tried-that-td5488277.html
ASKER
Hi andreas,
Cancel my last post. I've just realised that the cause was. My original problem was with .pl files, but I was testing your solution with a file with no extension, e.g.:
vim testfile
but it seems the problem would never have occurred with that last scenario.
Thanks for the link!
tel2
Cancel my last post. I've just realised that the cause was. My original problem was with .pl files, but I was testing your solution with a file with no extension, e.g.:
vim testfile
but it seems the problem would never have occurred with that last scenario.
Thanks for the link!
tel2
Ok but thanks for the feedback.
ASKER
That seems to work.
Where did you get that from? Can you provide a (blind) link, please? 8)