Browsing lines/columns in a big file in VSCode

Viewed 292

I work with big flat database files which I like to inspect at line/column.

I have a tool which generates a log with hundreds of lines like:

code --goto path/to/my/file:line:column

Visiting one such a spot works ok if I throw one such a line into the command line window and click it from there, but not from the editor (at least I have not found the way)

I would like to be able to have this log file open in the VSCode editor and hover/click in every line which would take me to the spot I want to visit in the big db file. Is this possible at all?

Should I convert my log file to some script format which supports the hover and click functionality?

Is there otherwise any extension available which can do the trick here?

Thanks a lot. Miguel

Edit

Using HTML Related Links v0.9.0

I guess we're almost there but it's still not working for me.

The concrete scenario I have is: I have a file

d:\Users\Abc.def\Git\lingware-data\test\spx\spm\spm_cfg3\spm_cfg3_tst_row_valid_lng_abbr.dbr

containing several lines of the type

code --goto d:\Users\Abc.def\Git\lingware-data\dct\spx\dct.u08:176:36

(probably code is not needed, I tried with and without it)

In my settings.json file:

"files.associations": { ".u08": "csv (pipe)", ".dbr": "html" },
"editor.largeFileOptimizations": false,
"html-related-links.include": {
   "html": [
      { "find": "--goto ([a-z:]+[^:]+):(\\d+):(\\d+)",
        "filePath": "$1",
        "lineNr": "$2",
        "charPos": "$3"
      }
   ]
}

if I use "plaintext" as languageId I don't get the HTML related links section displayed in the Explorer area, so I am using "html" - I have updated to v0.9.0 of the extension, and what I continue seeing in the explorer view is:

"d:\Users\Abc.def\Git\lingware-data\dct\spx\dct.u08 d:\Users\Abc.def\Git\lingware-data\test\spx\spm\spm_cfg3\d:\Users\Abc.def\Git\lingware-data\dct\spx\dct.u08"

If I click on it nothing happens I hope this is more or less clear.

What am I doing wrong?

*** edit *** Installed v0.9.1. Enabled Developer console to debug click behavior on a row. What get now is:

[Extension Host] Clicked on: d:\Users\Miguel.Duran\Git\lingware-data\dct\spx\dct.u08
console.ts:137 [Extension Host]     goto: 175:28
2 Answers

You can use the extension HTML Related Links v0.9.0 (it not only applies to HTML)

Define this in settings.json

"html-related-links.include": {
    "plaintext": [
      { "find": "--goto ([^:]+):(\\d+):(\\d+)",
        "filePath": "$1",
        "isAbsolutePath": true,
        "lineNr": "$2",
        "charPos": "$3"
      }
    ]
  },
"html-related-links.removePathFromLabel": true

After loading the log file you can lock the Explorer View HTML RELATED LINKS to this file. Use lock button in top right of the view. Now only changes to this log file will update the view.

In an absolute path the label will contain the path and the view adds the directory path at the end. You can remove the path from the label with the setting html-related-links.removePathFromLabel

Click on a row in the view and that file will be opened to the given line:char position.

If on Windows the path is absolute you have to specify the drive first because it contains a :

"find": "--goto ([a-z]:[^:]+):(\\d+):(\\d+)"

Edit

There was a small typo in the regular expression string (need escaping the escape char).

Add possibility for absolute paths.

I would like to be able to have this log file open in the VSCode editor and hover/click in every line which would take me to the spot I want to visit in the big db file.
Is this possible at all?

If you visualize your file in a VSCode terminal, VSCode 1.70 (July 2022) will offer a way.

See issue 140780 ("Jump to line+column in terminal links (format <path> l:c)"), PR 153957 ("Detect terminal links with space, then line:col") and PR 155904 ("Ensure folders with spaces don't impact link line/col")

To test, you can open a terminal and run echo ./myFile.txt 10:5 (replacing the filename with one that exists).

When you click to open the file, it should open to line 10, column 5.

This is available today (July 2022) in Code insiders.

Ensure folders with spaces don't impact link line/col

Related