7

When I paste into vim I often get a # character at the start of each line I've pasted.

Is there an easy way I can remove the first char on N lines (without regex)?

Thanks!

Alistair Colling
  • 1,363
  • 2
  • 19
  • 29

2 Answers2

5

Go to the first occurrence of # in the pasted text.

Enter blockwise visual mode.

ctrl-V 

Select first character in each line pasted.

<count>j

where count = N - 1

Delete the selected text.

x

Btw, your concern should have been to avoid getting # altogether when you paste. The solution to which is :set paste

Sagar Jain
  • 7,475
  • 12
  • 47
  • 83
5

Method 1:

Select these N lines and press :, the command line will look like this

:'<,'>

complete the command as :'<,'>normal x and press Enter

Method 2:

Say the the number of first line and last line you pasted in are startNumber and endNumber, just use command line:

:startNumber,endNumber normal x
fujianjin6471
  • 5,168
  • 1
  • 36
  • 32