Friday, February 4, 2011

Re: A tricky yank task

Hello!


I have a question about your command.
Could you explain, what the 


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

|g/ does?

I searched :help g/ but could not find anything.

I simply don't understand it.

Thanks in advance!

Asis

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

--
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

No comments: