I'd like to copy these to a file, but in a speculative future case, I might want to delete them. I might need to find a regex to substitute intervening data with a single blank line.
The highlighting shows it's matching a multiline block but global
yank
only gets the first line in the block.
These blocks can contain one blank line between lines with all non-lowercase. In some cases, the keyword can follow not(non-lowercase) on a line. Otherwise, I don't want any lines having mixed case or lowercase text. I would rather exclude that leading not(non-lowercase) if possible.
Gvim Version 7.3
In this example case, the keyword is MISHNAH. The highlight seems as if this regex would work:
/MISHNAH\_[^a-z]\+/
but
qAq
:g/MISHNAH\_[^a-z]\+/y A
or
:g/MISHNAH\_[^a-z]\+/d
only get the lines having the keyword.
EXAMPLE DATA:
CHAPTER I
MISHNAH. FROM WHAT TIME MAY ONE RECITE THE SHEMA' IN THE EVENING?
FROM THE TIME THAT THE PRIESTS ENTER [THEIR HOUSES] IN ORDER TO EAT THEIR
TERUMAH [1] UNTIL THE END OF THE FIRST WATCH. [2] THESE ARE THE WORDS OF R.
ELIEZER. THE SAGES SAY: UNTIL MIDNIGHT. R. GAMALIEL SAYS: UNTIL THE DAWN ...
EXAMPLE OF MORE BELONGING UPPERCASE TEXT AFTER ONE BLANK LINE
GEMARA. On what does the Tanna base himself that he commences: FROM WHAT TIME? [6]
Furthermore, why does he deal first with the evening [Shema']? Let him begin with the morning
... A whole lot of lines ...
HERE IS A LINE I DON'T WANT
but he says two blessings before and one after.
R. Mani said: He who recites the Shema' in its proper time is greater than he who studies the
Torah. [51] For since it says, HE WHO SAYS LATER LOSES NOTHING, BEING LIKE A MAN
WHO READS IN THE TORAH, we may conclude that one who recites the Shema' at its proper
time is superior. MISHNAH. BETH SHAMMAI SAY: IN THE EVENING EVERY MAN
SHOULD RECLINE AND RECITE [THE SHEMA'], AND IN THE MORNING HE SHOULD ...
ACTED AGAINST THE OPINION OF BETH HILLEL.
(1) This seems to be simply a periphrasis for `if a man is told in a dream'. Two explanations are
then possible of what follows. (i) If he dreams and the dream so far comes true that a sword is
placed on his neck, still he should pray. (ii)
... A whole lot of lines ...
Even if he only dreams this, he should still pray etc. (R. Bezalel of Regensburg.)
I want to get this:
MISHNAH. FROM WHAT TIME MAY ONE RECITE THE SHEMA' IN THE EVENING?
FROM THE TIME THAT THE PRIESTS ENTER [THEIR HOUSES] IN ORDER TO EAT THEIR
TERUMAH [1] UNTIL THE END OF THE FIRST WATCH. [2] THESE ARE THE WORDS OF R.
ELIEZER. THE SAGES SAY: UNTIL MIDNIGHT. R. GAMALIEL SAYS: UNTIL THE DAWN ...
EXAMPLE OF MORE BELONGING UPPERCASE TEXT AFTER ONE BLANK LINE
time is superior. MISHNAH. BETH SHAMMAI SAY: IN THE EVENING EVERY MAN
SHOULD RECLINE AND RECITE [THE SHEMA'], AND IN THE MORNING HE SHOULD ...
ACTED AGAINST THE OPINION OF BETH HILLEL.
I'd like to exclude the leading time is superior.
And also exclude lines that begin with non-lowercase and then
continue with not(non-lowercase), such as:
GEMARA. On what does the Tanna base himself that he commences: FROM WHAT TIME? [6]
I have found that perl's '~= m' (match) has an 's' switch to view the data as a string with embedded newlines. My problem seems to be that I don't know how I can get vim to do that. I copy the EXAMPLE DATA to a file called 'foo.txt' and run a perl script [on win cmd line] which can do:
perl -e "$n=chr(10);$d=join('', <>);$r='(MISHNAH(?:[^a-z]|\n)+)';while ($d =~ m/$r/sg) {print $1 . $n}" foo.txt
time is superior
deleted along with the rest of the line it’s on, or left in the file?:g
command into a:g!
command. I'll update the solution.