6

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,233
  • 2
  • 12
  • 27

2 Answers2

4

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
  • 6,909
  • 11
  • 43
  • 75
4

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,028
  • 1
  • 34
  • 32