This is some lines of text in a file. I need to remove certain block of text using vi editor.
An aurora (plural: auroras or aurorae) is a natural light display in the sky particularly in the high latitude (Arctic and Antarctic) regions, caused by the collision of energetic charged particles with atoms in the high altitude atmosphere (thermosphere).
Most aurorae occur in a band known as the auroral zone[2][2] which is typically 3° to 6° in latitudinal extent and at all local times or longitudes.
The auroral zone is typically 10° to 20° from the magnetic pole defined by the axis of the Earth's magnetic dipole. During a geomagnetic storm, the auroral zone will expand to lower latitudes. The diffuse aurora is a featureless glow in the sky which may not be visible to the naked eye even on a dark night and defines the extent of the auroral zone.
I have a input file like above. In this file I have to remove certain occurrences of a block of text like the following.
Most aurorae occur in a band known as the auroral zone[2][2] which is typically 3° to 6° in latitudinal extent and at all local times or longitudes.
So, I am using following command which is not working :
:g/^Most/,/auroral/,/longitudes./d
I am deleting the lines starting with Most , auroral in the mid and longitudes at the end.
There are distinct limits on what you can do, but in the context, you could use:
to delete a
whileloop where thewhileis at the start of a line up to the close brace at the start of a line.The
:g/^while/part searches globally for lines that start withwhile. What follows is anexcommand that is executed for each matched line. The command is.,/^}/d, which means from the current line (.) to the next line starting with close brace (/^}/) do a delete (d). You can use things like backward searches or relative motions (?^{?or.-3or.+10) as well.It is difficult to tell from the mangled appearance of the comment exactly what you have in mind (not your fault – comments don’t preserve useful formatting.)
That is simple, and I don’t see how the
coolhas any effect on it:This is isomorphic with my original answer.