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

  • Home
  • SEARCH
  • 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 8649591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:35:58+00:00 2026-06-12T13:35:58+00:00

I have a series of vim commands that write the selected block to a

  • 0

I have a series of vim commands that write the selected block to a temporary file, run a function (knitcite) on that file, and then read in another file:

w! ~/.vbuf <CR> 
!knitcite ~/.vbuf ~/.vbuf <CR> 
r ~/.vbuf <CR>

If I’ve selected a block of text in visual mode before running the first command, it becomes

:'<,'>w! ~/.vbuf <CR>

passing the selected contents to the file, as I need. I can put this into a simple vim function in my .vimrc, but cannot figure out how to pass the contents of the visual selection to the function. If this were a single command instead of three commands, I could do this with a visual map, but not sure how to do it with three commands. something like:

command knitcite call Knitcite()
func! Knitcite()  
exec "w! ~/.vbuf <CR>"
exec "!knitcite ~/.vbuf ~/.vbuf <CR> "
exec "r ~/.vbuf <CR>"
func

but this doesn’t get any data passed in from the visual block. I guess I need to give an argument to my Knitcite function but cannot figure out what it would be. (Seems that this might be related to this SO question but I couldn’t figure out how to generalize from that answer.)

  • 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-06-12T13:36:00+00:00Added an answer on June 12, 2026 at 1:36 pm

    The simplest thing to do would be to use as a filter:

    :'<,'>!knitcite
    

    If knitcite doesn’t work in filter mode (often it uses - to signify stdin as a filename, other options may apply) you could wrap it in a shell script:

    #!/bin/bash
    tmpname="/tmp/$(basename "$0").tmp$RANDOM"
    
    trap "rm -f '$tmpname'" ERR INT EXIT
    knitcite <(cat) "$tmpname"
    cat "$tmpname"
    

    Otherwise, it looks like you want to replace the visual selection with the output:

    :'<,'>w! ~/.vbuf
    :'<,'>d _
    :silent! !knitcite ~/.vbuf ~/.vbuf.out
    :'<-1r ~/.vbuf.out
    

    Note

    1. the use of a separate temporary file for the output: otherwise, trouble may arise on most platforms, where the truncation of the output file might happen before the input has been read!
    2. the use of the black hole register ("_) with the :delete command to avoid clobbering any registers
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have series of curl commands that I want to translate into straight up
I have a series of functional tests against a web application that correctly run,
I have a series of if statements in a function like this: if time
I have a series of logging breakpoints in Xcode4 that I'm using to selectively
I have a series of divs that slide down using -webkit-transform from a negative
I have a series of images that get loaded for a carousel, and it
I have a series of grouped values that follow a specific format and would
I have a series of CodedUI test methods that make up a single test
I have a series of array formulas in Excel that key off of each
I have a series of queries in a stored procedure that are connected with

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.