-1

I was practicing inserting text in multiple lines in vim, as given in this tutorial and this SO answer as well.

But this technique doesn't seem to work if the text to be inserted is something like "std::" or even "std:" The colon at the end seems to mess up something.

For a code like

cout << "Hello World" << endl;
cout << "Yo Yo!" << endl;

I take my cursor to the first line, at 'c', press, 'Ctrl+V' to enter Visual Block mode. Then I press 'j' to select the next line as well. Then I press 'I' to enter the special insert mode and then I enter the text I want to insert. Then I press 'Esc'

For any simple text such as 'try_',

it gives

try_cout << "Hello World" << endl;
try_cout << "Yo Yo!" << endl;

But if my text is something like 'std::'

it just gives

std::cout << "Hello World" << endl;
cout << "Yo Yo!" << endl;

It just ends up inserting text on the first line, leaving the others intact.

Please guide.

Community
  • 1
  • 1
Cheeku
  • 833
  • 1
  • 8
  • 22
  • You forgot to tell us what happens when you type `std::` and to describe what you do. – romainl Apr 06 '15 at 07:01
  • @romainl Actually sir! I did mention that it just ends up inserting text on the first line when I type 'std::' and does not replicate the action for all lines. I feel describing what I do is redundant. I have provided two links which give the same set of steps that I have replicated. Though, I will edit to *explicitly* note these two – Cheeku Apr 06 '15 at 07:12
  • See? Your question isa lot better, now. Do you have some autocompletion plugin? – romainl Apr 06 '15 at 08:26
  • @romainl No. No plugins at all. Whatever comes in utopic package – Cheeku Apr 06 '15 at 08:37
  • @romainl Ubuntu 14.10 – Cheeku Apr 06 '15 at 13:59

1 Answers1

0

This is caused by vim's cindent setting. When you type std:, vim assumes you are creating a label named "std" and reduces its indentation to 0. For some reason, this is messing with the visual block insert. Enter :set nocindent to temporarily get the behavior you desire. I'm not sure if this can be fixed in a more permanent fashion, but you probably don't do this very often.

Dylan MacKenzie
  • 632
  • 5
  • 13