I encountered an oddity when trying to use the substitute() function to 
prepend '# ' to the start of every line returned from a command.

A very simplified example:

I might expect
:echo substitute("a\na",'^','b','g')
to echo "ba\na"

But, why does
:echo substitute("a\na",'\_^','b','g')
also echo "ba\na" -- instead of "ba\nba"?

In the end, my ugly workaround was to use:
join(map(split(system(...),"\n"),'substitute(v:val,x,y,z)'),"\n")
where I wanted just:
substitute(system(...),x,y,z)

-- 
Best,
Ben

For anyone reaaally curious, I was wrapping a git log command from 
within a gitrebase buffer (and could more-than-probably stand to put it 
in a function):

:%s/^pick \(\S\+\) .*$/\=join([submatch(0)] + [ "# {{{1" ] + 
map(split(system('git log -p 
'.submatch(1).'~1..'.submatch(1)),"\n"),'substitute(substitute(v:val,"\r","","g"),"^","#
 ","g")') + [ "# }}}1" ],"\n")/

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

Subscription settings: http://groups.google.com/group/vim_use/subscribe?hl=en

Reply via email to