in vim, with

vim file +10

I can open the file in the line 10, with

vim file +10d

I can delete the line 10, but how I can delete the line and exit of vim? or how I can delete the line without open vim ?

vim file +10d -c wq


vim file +10d -c x

vim --help

 -c <command>        Execute <command> after loading the first file
| improve this answer | |
  • to me it seems cleaner to write either vim file +10d +x or vim file -c 10d -c x. Note: You can use up to 10 "+" or "-c" commands. – Antoine Colson Jul 5 at 6:30

To do that it would be better to use sed like this:

sed -i 10d file
| improve this answer | |
  • 1
    but, I like use the vim commands – juanpablo Jun 7 '12 at 15:03
  • 1
    you can execute multiple commands, but it will always open vim and then close. i suggested sed because you said "without open vim". vim file -c 10d -c x – johnshen64 Jun 7 '12 at 15: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.