Saturday, November 2, 2013

Re: Insert comand output on current text

Ben has answered your question directly ("I want to write the output of ...") using redir, but a more natural (to me) approach for this would be (assuming you want the ch007.html text at the current line)

:let n = -1
:1,.g/^# /let n += 1
''
:put =printf('ch%03d.html, n)

The :g leaves the cursor at the last match so '' is used to go back to where you started. (C programmers know about printf, but in case you don't %03d means print an integer in a field 3 characters wide with leading zeroes.)

Regards, John Little

--
--
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 because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: