What I have so far:
function! GetMarker()
return system('echo $random `date` | md5sum | cut -d" " -f1')
endfunction
I would like to be able to do a :getmarker and have it insert the output of that system command at my cursor, with no new lines.
Also what is the difference between function! and function?
Edit: before any of you ask, I need the random string to mark sections in my code so I can find them again by referencing my notes in my todo wiki.
Edit1. Take two. Trying to absorb the feedback from Luc. Without temp file (
readfile()turned out to be not available in VIM 6.x I have on some systems).:putcan’t be used because it works line-wise. I replaced<Esc>...<Insert>with the all better<C-O>. I left redraw in, as it helps for the cases of called command produces output to the stderr.Or using
<C-R>=:Exclamation on the end of command most of the time means force to execute. (Looking in the
:helpis advised since different commands use!differently, but VIM tries to document all forms of the commands.) In the case of thefunctionit tells VIM to override previous definition of the function. E.g. if you put the code above into thefunc1.vimfile, first time:source func1.vimwould work fine, but the second time it would fail with error that function InsertCmd is already defined.I did once before try to implement something similar here. I’m not good at VIM programming, thus it looks lame and the suggestion from Luc should take precedence.
Here it goes anyway:
Despite being lame, it works though.