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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:04:10+00:00 2026-05-12T05:04:10+00:00

I would like to get an AND -operator to the following Vim command :command!

  • 0

I would like to get an AND -operator to the following Vim command

:command! -nargs=1 GrepSource :! grep <args> `sed -n 's/^source \(.*\)/\1/p' %`

such that I can use the command to find sources at

# source <path>
# . <path> 
source <path>
. <path>

I am not sure whether it is possible or not to get AND -operator to SED or Vim.

How can you add an AND -operator to the SED command?

  • 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-12T05:04:10+00:00Added an answer on May 12, 2026 at 5:04 am

    You can just use Vim regular expressions to find the <path> name, instead of using sed:

    :command! -nargs=1 GrepSource :exe printf("!grep '<args>' '%s'", matchstr(getline('.'), '^#\=\s*\%(source\|\.\)\s*\zs\f\+'))
    

    I think that command should do what you want. You can use the next command to test what is happening (‘exe’ is changed to ‘echo’):

    :command! -nargs=1 GrepSourceTest :echo printf("!grep '<args>' '%s'", matchstr(getline('.'), '^#\=\s*\%(source\|\.\)\s*\zs\f\+'))
    

    The command must be used on a line in one of the following forms:

    # source <somefile>
    # . <somefile>
    source <somefile>
    . <somefile>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I would like to achieve here is a user selects an operator, e.g.
I have an NSTimeInterval that is stored as a double. I would like to
Essentially, what I'd like is for the value object to maintain a reference to
I'm trying to build a list of functions that can be used for arbitrary
I wish to implement a binary tree using references instead of using pointers (which
Say you have some target class with some methods on it: class Subject {
I'm a beginner in Perl and I'm trying to build in my head the
I have a class which I use to record a value in a given
Hello I have some touble overloading operators for std::list. I store pairs in a
I have a linked list structure: struct SomeLinkedList { const char* bar; int lots_of_interesting_stuff_in_here;

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.