I was looking at this vimgolf challenge, and I thought it would be nice to delete specific lines by address. I know I can do this with :<line_number>d, but is there a way to list multiple line numbers for d to be run on? I imagine something like this: :1,4,32d, but of course it doesn't work.

How would this be done?


The bar | command can be used to separate multiple commands in a single command statement.

Your example could be written as :1d|4d|32d


  • 2
    This executes the commands sequentially -- so :1d|4d would delete the first line, then delete the fourth line, which was the fifth line before the first line was deleted. Doing it in reverse would allow it to be more intuitive -- :32d|4d|1d.
    – evilsoup
    Dec 12 '15 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.