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!
To remove all lines containing a particular string in the vi or Vim text editors, you can use the g command to globally search for the specified string and then, by putting a "d" at the end of the command line, specify that you want all lines containing the specified string deleted.
To delete a line in Vi or Vim, switch to normal mode first. If you're into command mode or insert mode, you can switch back to normal mode by pressing Escape. Highlight the line that you want to delete, then hit dd or D on the keyboard. The editor will automatically remove the whole line from the file.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With