Re: Insert comand output on current text
Am 01.11.2013 20:44, schrieb Cesar Romani: On 01/11/2013 01:32 p.m., Ben Fritz wrote: On Friday, November 1, 2013 10:29:12 AM UTC-5, andalou wrote: On the current text I'd like to insert the string ch007.html (without quotes) without newlines inserted. Is it possible? This request I don't understand at all. Please give a before-and-after example. Let's say, I have before: Véase el siguiente enlace en el libro and after: Véase el siguiente enlace ch007.html en el libro Ok, but you can achieve this by moving the cursor to the end of enlace, typing 'a' to enter insert mode, then typing ch007.html. But I'm sure you know how to do that. So what are you really asking? What do you want to do, to get to your resulting text? If I go after the end of enlace and do :1,.s/^# //n I get, say: 8 matches on 8 lines then I'd like to have ch007.html after enlace. If the above command outputs: 35 matches on 35 lines then I'd like to have ch034.html after enlace. I suppose, I can do it manually. Thanks anyway. You didn't mention that 8 is connected with 7. :substitute sets v:statusmsg :h v:statusmsg :let filename = printf('ch%03d.html', matchstr(v:statusmsg, '\d\+')-1) Append text after EOL: :call setline('.', getline('.'). filename) :exec 'normal! A'. filename :s/$/\=filename -- Andy -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Insert comand output on current text
On Friday, November 1, 2013 2:44:35 PM UTC-5, andalou wrote: If I go after the end of enlace and do :1,.s/^# //n I get, say: 8 matches on 8 lines then I'd like to have ch007.html after enlace. If the above command outputs: 35 matches on 35 lines then I'd like to have ch034.html after enlace. OK, now THAT is a much better problem description. We can work with that. I suppose, I can do it manually. Thanks anyway. My comment about doing it manually was because your initial problem description gave NO indication as to where ch007 came from, nor how you wanted to insert it. Actually, you STILL give zero indication how you want to insert it. How do you determine where in the line to insert the number? To get everything ready for insertion, do: :redir = var :1,.s/^# //n :redir END :let @=ch.printf(%03d,(substitute(var, '^\(\d\+\).*', '\1', '')-1))..html Now you can paste with p and you'll get ch007.html or similar at the cursor. If that's not what you want to do for insertion, you need to share where the text should be inserted, what you want to do to insert it, etc. -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Insert comand output on current text
On 02/11/2013 01:06 p.m., Ben Fritz wrote: [...] My comment about doing it manually was because your initial problem description gave NO indication as to where ch007 came from, nor how you wanted to insert it. Actually, you STILL give zero indication how you want to insert it. How do you determine where in the line to insert the number? To get everything ready for insertion, do: :redir = var :1,.s/^# //n :redir END :let @=ch.printf(%03d,(substitute(var, '^\(\d\+\).*', '\1', '')-1))..html Now you can paste with p and you'll get ch007.html or similar at the cursor. If that's not what you want to do for insertion, you need to share where the text should be inserted, what you want to do to insert it, etc. Many thanks Ben. It is what I wanted. Regards, -- Cesar -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Insert comand output on current text
On 02/11/2013 05:20 p.m., John Little wrote: 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 Thanks Ben and John. Best regards, -- Cesar -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Insert comand output on current text
On Friday, November 1, 2013 10:29:12 AM UTC-5, andalou wrote: On the current text I'd like to insert the string ch007.html (without quotes) without newlines inserted. Is it possible? This request I don't understand at all. Please give a before-and-after example. Let's say, I have before: V�ase el siguiente enlace en el libro and after: V�ase el siguiente enlace ch007.html en el libro Ok, but you can achieve this by moving the cursor to the end of enlace, typing 'a' to enter insert mode, then typing ch007.html. But I'm sure you know how to do that. So what are you really asking? What do you want to do, to get to your resulting text? -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Insert comand output on current text
On 01/11/2013 01:32 p.m., Ben Fritz wrote: On Friday, November 1, 2013 10:29:12 AM UTC-5, andalou wrote: On the current text I'd like to insert the string ch007.html (without quotes) without newlines inserted. Is it possible? This request I don't understand at all. Please give a before-and-after example. Let's say, I have before: Véase el siguiente enlace en el libro and after: Véase el siguiente enlace ch007.html en el libro Ok, but you can achieve this by moving the cursor to the end of enlace, typing 'a' to enter insert mode, then typing ch007.html. But I'm sure you know how to do that. So what are you really asking? What do you want to do, to get to your resulting text? If I go after the end of enlace and do :1,.s/^# //n I get, say: 8 matches on 8 lines then I'd like to have ch007.html after enlace. If the above command outputs: 35 matches on 35 lines then I'd like to have ch034.html after enlace. I suppose, I can do it manually. Thanks anyway. -- Cesar -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Insert comand output on current text
On Wednesday, October 30, 2013 7:26:44 PM UTC-5, andalou wrote: I want to write the ouptut of 1,.s/^# //n into the current text. Let's say that the output of the above command is: 8 matches on 8 lines You can get this output with the :redir command. Put it in the unnamed register: :redir @ :your command here :redir END Now paste with p On the current text I'd like to insert the string ch007.html (without quotes) without newlines inserted. Is it possible? This request I don't understand at all. Please give a before-and-after example. -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Insert comand output on current text
I want to write the ouptut of 1,.s/^# //n into the current text. Let's say that the output of the above command is: 8 matches on 8 lines On the current text I'd like to insert the string ch007.html (without quotes) without newlines inserted. Is it possible? Many thanks in advance, -- Cesar -- -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.