21

I have created a function to search all double lines in a file.

I use the "line-number"g/.*/d to delete the line.

However I would like to confirm if a line has to be deleted or not, like the s/..//gc command

Is it possible to delete a certain line with the global or substitute
command and confirm every action?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Reman
  • 7,931
  • 11
  • 55
  • 97

2 Answers2

17

Why not try a substitute command instead of the delete command?

"line-number"s/^.*$\n//c
Prince Goulash
  • 15,295
  • 2
  • 46
  • 47
7

If I wanted to delete lines in a file and confirm each one, I would:

  • search for the first one
  • if I want to delete it, press dd
  • search for the next one with n
  • if I want to delete that, press ., else n again
Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • 1
    it is not possible in my case. I do a check of every line with every other line and put the double line numbers in a list. Then I use the `\%l` code to put them all in a @/ variable and return it to the file. There in my opinion no way to "go to next" using a `\%l` in the search. – Reman Jul 09 '11 at 08:08