0

Let's say I have some text:

ipsum
ipsum dolor
ipsum dolor sit

I want to add the word "Lorem" in front of each line.

Loremipsum
Loremipsum dolor
Loremipsum dolor sit

I can do this by:

  • Entering visual block mode at the first line,
  • Going down 2 lines
  • Entering insert mode with Shift-I
  • Typing Lorem
  • Exit insert mode (with Esc)

It will indeed put "Lorem" in front of each line but only after exiting insert mode.

I would like for multiple cursors to appear, and whatever I type would appear on all three lines, not just the top one.

Is this possible with Vim or a plugin?

Vivian De Smedt
  • 16,336
  • 3
  • 18
  • 37
Amarakon
  • 261
  • 2
  • 7
  • Other solutions: v2j:s/^/Lorem (the first bit v2j can be replaced by your favorite way to enter a range for that chunk of text), v2j:norm! ILorem, ILorem <esc>j.j., etc. :[range]normal! . is also really powerful. – D. Ben Knoble Aug 28 '22 at 03:13
  • Possible duplicate: https://vi.stackexchange.com/a/4312/10604 – D. Ben Knoble Aug 30 '22 at 14:21

1 Answers1

1

It is not possible in Vim without special customization.

The vim-visual-multi plugin offers such functionality.

For your use case once vim-visual-multi is installed.

  • Use Ctrldown to select the part of the column you want to edit (like Ctrlv + down would do in standard Vim),
  • Use i to switch to insert mode,
  • Type your text,
  • Leave insert mode Esc,
  • Leave multiple cursor mode Esc.

All the row are edited at the same time.

vim-visual-multi is actually much more capable but this cover your use case.

Vivian De Smedt
  • 16,336
  • 3
  • 18
  • 37