relative paths in search results



  • i wonder whether its possible to get the search-in-files list to use relertive paths instead of absolute paths, for example if i seached in file in the folder C:\folder\folder2 i want the resultlist for example for resuls in the file C:\folder\folder2\folder3\file.txt to only show .\folder3\file.txt instead of the whole C:\folder\folder2\folder3\file.txt. The follwing image shows my problem quite well:

    https://i.imgur.com/MSy5p0J.png

    i searched in ‘C:\Users\Daniel\Documents\My Games\Wesnoth1.14\data\add-ons\World_Conquest_II’ and i cannot see the actual filenames at all unless i move the searchresults list to someplace where it would block the usual codeview compltely, (the window is maximized. this is a small screen and putting the list to the bottom is also not really an option.)

    ps: is it possible to upload images directly to this post? i couldn’t figure out how.



  • I don’t think that feature currently exists. FAQ Desk: Feature Request explains the right location to ask for new features.

    Regarding results too wide to see the actual filenames: if you click in the Results window, and use Ctrl+A to select all, you can then paste the results into a normal Notepad++ editing pane (such as after File > New). If you trim out all the lines that start with a tab (such as Find what:(?-s)^\t.*\R, Replace with:`` (blank), enable Regular expression), it will just leave (mostly) just the filename rows, but delete the result rows… After that, you can do a search/replace (this time, case insensitive, without regular expression, so the windows backslash doesn’t become meaningful), where you search for the c:\folder\folder2\ and replace with .\ … then all the files are relative. But that is only a workaround, and won’t have the nice features of the find-in-files results window, sorry.

    Embedded images: if you noticed the COMPOSE ? in the upper-right of your text-edit window, you could have clicked on it, and it would have directed you to Markdown documentation, where it says to embed an image, use the syntax ![](https://url.of/image.png)

    Also, you should look at this old post to find other good formatting hints for this forum. ( @Scott-Sumner was thinking about turning that old post into an entry on our FAQ Desk, but apparently hasn’t found the Round Tuit™ yet. I keep hoping my continued @-mentions will help him find the Tuit™ :-) )

    [edit: fix phrasing, especially incomplete sentence; reorder paragraphs]



  • ok thx, i’ll consider filing a report on gh, i just asked here first becasue i hoped it might already exist and also becasue this place seemed more active than gh.



  • @gfgtdf

    I really like this idea. I’d suggest a Preferences… option to replace leading Directory: text with ... in the Find result panel.

    As an example, if the Directory: box contains the following when the Find in Files is executed:

    C:\Users\Daniel\Documents\My Games\Wesnoth1.14\data\add-ons\World_Conquest_II
    

    hits in the file :

    C:\Users\Daniel\Documents\My Games\Wesnoth1.14\data\add-ons\World_Conquest_II\lua\effects.lua
    

    would simply show up in the Find result panel as :

    ...\lua\effects.lua (2 hits)
    


  • I would think (haven’t checked the Notepad++ source code) that in order to jump to hits when they are double-clicked in the Find result panel, Notepad++ actually reads the data out of the panel itself to determine file path…so it can switch to (or open) the necessary file and jump to the correct line.

    Thus, I would modify my previous suggestion from showing only this in the Find result panel:

    ...\lua\effects.lua (2 hits)
    

    to displaying something more along these lines:

    ...\lua\effects.lua (2 hits) - C:\Users\Daniel\Documents\My Games\Wesnoth1.14\data\add-ons\World_Conquest_II\...
    

    That way Notepad++ could put the complete path back together when needed.


Log in to reply