Confirm line delete

2019-04-03 17:12发布

问题:

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?

回答1:

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

"line-number"s/^.*$\n//c


回答2:

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


标签: vim line confirm