Skip to content

--vimgrep doesn't satisfy vim's spec for multi-line searches #1866

@poetaman

Description

@poetaman

NOTE from BurntSushi: This issue has been re-classified as a bug that was discovered in the course of discussion. There's too much context here to split it apart, which GitHub doesn't really make easy to do anyway. So I've re-purposed this issue for the bug described in the title. The main details of the bug are described here: #1866 (comment)

Below is the original issue.


Describe your feature request

Vim recently added a new feature called "text properties" that can be used to highlight text. All it needs to know to highlight is:

  • lnum : line number where match begins
  • col : column (counted in bytes) where match begins
  • end_lnum : line number where match ends
  • end_col : column (counted in bytes) where match ends

Ideally there would be an option like --json-pos that just prints positions of matches for each file, perhaps in json format like following. If that is not possible or two cumbersome, is there a way I can already do this in a performance efficient way using ripgrep?

{
  {
    "file": "fileA.txt",
    "positions": [
      {
        "lnum": 10,
        "col": 4,
        "end_lnum": 12,
        "end_col": 7
      },
      {
        "lnum": 15,
        "col": 3,
        "end_lnum": 15,
        "end_col": 5
      },
      {
        "lnum": 17,
        "col": 12,
        "end_lnum": 20,
        "end_col": 10
      }
    ]
  },
  {
    "file": "fileB.txt",
    "positions": [
      {
        "lnum": 1,
        "col": 4,
        "end_lnum": 1,
        "end_col": 7
      },
      {
        "lnum": 30,
        "col": 3,
        "end_lnum": 31,
        "end_col": 5
      }
    ]
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug.rollupA PR that has been merged with many others in a rollup.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions