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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:14:56+00:00 2026-06-04T04:14:56+00:00

This is a follow-up to my question about using multi-line regex in Vim .

  • 0

This is a follow-up to my question about using multi-line regex in Vim.

A quick explanation: I have blocks of text tagged with #tags and separated by a blank line. I want to filter out all blocks that include a specific tag. I was helped with regex here (thanks!), so I constructed the following command:

command -nargs=1 TagSearch g/^\(.\+\n\)\{-}.*#<args>.*/y a | vnew | put a | %s/^#.*<args>.*\n/&\r 

Hence, doing a :TagSearch tag should:

  1. Search for the #tag.
  2. Paste all corresponding Text Blocks into a new vertical buffer.
  3. Add a blank line between the Text Blocks in the new buffer.

Q1: When I do each step separately, everything works. But the multi-command only pastes the first matching text block into the new buffer. Why?

Q2: How could I make the command accept multiple arguments (in case I want to search for several #tags at once)? Thanks!

  • 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-04T04:14:56+00:00Added an answer on June 4, 2026 at 4:14 am

    One can use the following implementation.

    command! -nargs=* -bar TagSearch call CollectParagraphs([<f-args>])
    
    function! CollectParagraphs(tags) range
        let tags = len(a:tags) > 0 ? a:tags : [expand('<cword>')]
        let pats = map(copy(tags), '"\\.\\*#" . escape(v:val, "\\")')
    
        let v = winsaveview()
        let [sr, @/; lines] = [@/, '\V' . join(pats, '\&')]
        g//call extend(lines, getline(search('\n\n\zs', 'bnW'), line("'}")))
        let @/ = sr
        call winrestview(v)
    
        exe 'vnew' escape(join(tags), ' %#|\')
        set buftype=nofile bufhidden=hide noswapfile
        call setline(1, lines)
    endfunction
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow up to my previous question about using XMLHttpRequest() to post
This is a follow up question to a previous question I asked about calculating
Follow up to this question about GNU make : I've got a directory, flac
This is a follow on from my previous question although this is about something
this is a follow-up question of mine. Suppose now I have a URL :
This is a follow-up to my previous question about developing Perl applications . Let’s
This question is a follow up to my previous question about getting the HTML
As kind of a follow up to this question about prefixes , I agree
Disclaimer: This is a follow-on question from my other question about NServiceBus which was
I have a question about precompiling ASP.NET web application projects from TeamCity. This is

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.