On 02/04/2011 09:03 AM, ConcreteVitamin wrote:
==========
Frankenstein (Mary Wollstonecraft Shelley)
- Highlight Loc. 23-24 | Added on 星期一, 一月 31, 2011, 09:04 下午
nothing contributes so much to tranquillize the mind as a steady
purpose--a point on which the soul may fix its intellectual eye.
==========
Frankenstein (Mary Wollstonecraft Shelley)
- Note Loc. 50 | Added on 星期一, 一月 31, 2011, 09:13 下午
Letter One talks about R. Walton is going to sea, heading to Russia,
saying farewell to his sister Margaret.
==========
Frankenstein (Mary Wollstonecraft Shelley)
- Highlight Loc. 92-93 | Added on 星期一, 一月 31, 2011, 10:08 下午
I have often attributed my attachment to, my passionate enthusiasm
for, the dangerous mysteries of ocean to that production of the most
imaginative of modern poets.
==========
Frankenstein (Mary Wollstonecraft Shelley)
- Note Loc. 99 | Added on 星期一, 一月 31, 2011, 10:11 下午
Letter Two says Walton has engaged some seamen and a vessel, waiting
to embark. He says he needs friends.
The task is: yank ALL my notes OR highlights at the same time.
For example, if I am to yank all my notes in the above text, it should
be:
Letter One talks about R. Walton is going to sea, heading to Russia,
saying farewell to his sister Margaret.
Letter Two says Walton has engaged some seamen and a vessel, waiting
to embark. He says he needs friends.
I find it very tricky. Could any one help me?
If you add an extra row of "======" at the bottom of the file,
you can use the following:
:let @a=''|g/^=\{10\}\n.*\n- Note\>/'}+;/^=\{10\}/-y A
which will accumulate your notes in the "a" register which you
can then paste in a new buffer with
"aP
This assumes that title-lines ("\n.*\n") and note/highlight ("\n-
Note.*\n" which could be "\n- Highlight.*\n" if you wanted
highlights instead of notes) lines are only ever one line each.
It breaks down as
let @a='' empty the register into which we're accumulating
g/^=\{10\} on every line with 10 "=" at the beginning
\n followed by a newline
.* followed by stuff (the title, but we don't care)
\n followed by a newline
- Note\> followed by a dash and the classification
(Note or Highlight) followed by other stuff
we don't care about
/ perform the following action(s)
'} from the "next paragraph break" mark
(a lazy way of writing "/^$/")
+ move the front of the range one line forward
(this can be omitted if you want blank lines
between your results)
; the continuation of the range ("through")
/^=\{10\}/ the next line containing 10 "=" at the beginning
(the reason this solution needs them at the
bottom of the file)
- adjust the range back one line so we don't
include the "=====" row. Optional if you want
such separators in your results.
y A yank that range, appending to register "a"
Hope this helps,
-tim
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php