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 8321097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:54:02+00:00 2026-06-08T22:54:02+00:00

In a shell I use the following function to create a filelist and pass

  • 0

In a shell I use the following function to create a filelist and pass it to vim.

Feels alright, but I lost the line reference, I open the files in correct order but then I have to search again for the text as the cursor starts at first line.

Actual function on ~/.bashrc

function vimgrep(){
   vim `grep -IR "$1" * | awk -F: '$1!=f{print ""$1"";f=$1}' | grep -v 'Test\|test'` +ls
}

function vimgrep2(){
   vim `grep -IR "$1" * | awk -F: '$1!=f{print ""$1"";f=$1}' ` +ls
}

Obs.: filelist must come from shell to vim, and then it must keep the line reference of the buffered files, just like with the results of :make when it catches any error (but without the bottom window [:cwindow]).

edited:
Ok… not so elegant, but I could pass the searched string to vim as +/”$1″, like:

   vim `grep -IR "$1" * | awk -F: '$1!=f{print ""$1"";f=$1}' ` +/"$1"

Would be better if the script doesn’t use a temporary file.

  • 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-08T22:54:04+00:00Added an answer on June 8, 2026 at 10:54 pm

    Vim also comes with a vimgrep command you could use

    function vimgrep() {
        local regex="$1"
    
        if [[ -z "$regex" ]]; then
            echo "Usage: $0 regex" 1>&2
            exit 1
        fi
    
        vim -c "vimgrep /$regex/ **"
    }
    

    Be careful of running it in a directory with a lot of files below it.

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

Sidebar

Related Questions

The following contents are in a file.i use a shell script to call a
I currently use the following command, but it's a little unwieldy to type. What's
Many Java applications that use shell scripts to configure their environment use the JAVA_HOME
I use emacs23.4 on window xp. So the shell-mode use windows cmd.exe. I encountered
I have a shell and I use pwd to show in which directory I
I'm trying to use a shell script to start a command. I don't care
Somehow if I use grunt shell to execute a pig script, it works fine
When looping recursively through folders with files containing spaces the shell script I use
To get the logcat from an Android device, I use adb shell logcat (also
I use shared hosting so I can't access to shell. I have CronsController and

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.