Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 913979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:38:35+00:00 2026-05-15T17:38:35+00:00

What I have so far: function! GetMarker() return system(‘echo $random `date` | md5sum |

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:38:37+00:00Added an answer on May 15, 2026 at 5:38 pm

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

    :function InsertCmd( cmd )
    :       let l = system( a:cmd )
    :       let l = substitute(l, '\n$', '', '')
    :       exe "normal a".l
    :       redraw!
    :endfunction
    
    :imap <silent> <F5> <C-O>:call InsertCmd( 'echo date \| md5sum \| cut -d" " -f1' )<CR>
    :map <silent> <F5> :call InsertCmd( 'echo date \| md5sum \| cut -d" " -f1' )<CR>
    

    :put can’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>=:

    :function InsertCmd( cmd )
    :       let l = system( a:cmd )
    :       let l = substitute(l, '\n$', '', '')
    :       return l
    :endfunction
    
    :imap <silent> <F5> <C-R>=InsertCmd( 'echo date \| md5sum \| cut -d" " -f1' )<CR>
    

    Also what is the difference between function! and function?

    Exclamation on the end of command most of the time means force to execute. (Looking in the :help is advised since different commands use ! differently, but VIM tries to document all forms of the commands.) In the case of the function it tells VIM to override previous definition of the function. E.g. if you put the code above into the func1.vim file, first time :source func1.vim would 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:

    :function InsertCmd( cmd )
    :       exe ':silent !'.a:cmd.' > /tmp/vim.insert.xxx 2>/dev/null'
    :       let l = readfile( '/tmp/vim.insert.xxx', '', 1 )
    :       exe "normal a".l[0]
    :       redraw!
    :endfunction
    
    :imap <silent> <F5> <Esc>:call InsertCmd( 'hostname' )<CR><Insert>
    :map <silent> <F5> :call InsertCmd( 'hostname' )<CR>
    

    Despite being lame, it works though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what I have so far: <script> $(document).ready(function(){ $(.entry-content img:first).addClass('postimage'); }); </script> As
In my database I have two columns named 'amount_raised' and 'funding_goal'. I would like
Here's what i have so far: function loadOff(){ $(document).ready(function(){ $(#eLoader).ajaxStop(function(){ $(this).hide(); $(#eventsContent).show(); var h
So far during my site development I have been storing all my jQuery functions
I have multiple javascript functions in my html page. One of them, by far
I have so far accomplished the below written thing.. I want to retrieve the
I have searched far and wide on the Internet but have not found anything
What I have so far: I have a form in PHP that contain the
This is what I have so far: [my1@graf home]$ curl -# -o f1.flv 'http://osr.com/f1.flv'
This is what I have so far - my dropbox public URL creation script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.