vim - How to delete a large block of text without counting the lines?

vim
Justin Ethier picture Justin Ethier · Mar 19, 2011 · Viewed 178.6k times · Source

In vim, I often find myself deleting (or copying) large blocks of text. One can count the lines of text and say (for example) 50dd to delete 50 lines.

But how would one delete this large block of text without having to know how many lines to delete?

Answer

paxdiablo picture paxdiablo · Mar 19, 2011

Go to the starting line and type ma (mark "a"). Then go to the last line and enter d'a (delete to mark "a").

That will delete all lines from the current to the marked one (inclusive). It's also compatible with vi as well as vim, on the off chance that your environment is not blessed with the latter.