I will frequently use visual mode and the "norm" command to quickly comment out several lines.
Let's say this is my text (line numbers added for clarity):
1. #include <iostream>
2. using namespace std;
3.
4. int main()
5. {
6. cout << "Hello world!\n";
7. return 0;
8. }
And my cursor is on line 6. I hit 'v', 'j', and then
:'<,'>norm 0i//
now my text is:
1. #include <iostream>
2. using namespace std;
3.
4. int main()
5. {
6. // cout << "Hello world!\n";
7. // return 0;
8. }
and my cursor is on the second '/' on line 7.
But now, every new line I open starts with '//'. For example, if I hit 'o', and then enter twice, it will look like this:
1. #include <iostream>
2. using namespace std;
3.
4. int main()
5. {
6. // cout << "Hello world!\n";
7. // return 0;
8. //
9. //
10. //
11. }
It will also do this with 'A<cr>'
and 'O'
.
What causes this? Is this a bug? Is there a way to get around it? It's not super annoying, but it does throw me off a little bit. That and I'm really curious at what causes this.
If it matters at all, I am using Ubuntu 15.04 and vim 7.4.488.