How to right mouse click File Open from current directory



  • Hi,

    When I try to use the Right Mouse click File Open menu item i have to specify the directory.

    For example if i have two files (File1.txt and File2.txt) in a directory and File1.txt has the following content then i can right mouse click the ‘/File2.txt’ and open it in a new tab
    File1.txt:

    ./File2.txt

    The problem is that witht he project that I am on does not include the director so the File1.txt content looks more like
    File1.txt

    File2.txt

    When I try to right mouse click File Open the above it is not recognized as a possible file to open.

    Can someone help me to allow for content liek ‘File2.txt’ to be recognized as a file in the current directory in Notepad++ ?

    Bonus - I noticed that when i double click the ‘File2.txt’ only the ‘File2’ is highlighted. Does anyone know how to set Notepad ++ so that the entire filename ‘File2.txt’ is highlighted?

    Thankyou

    Andrew



  • Hello, @ady-klaj, and All,

    Assuming for instance, that you have a file, named Blablah.txt, in folder C:

    And let’s suppose that you have this line in a file :

    xxxxx C:\Blablah.txt xxxxx
    

    I’ve added a second line of uppercase letters just to locate the present cursor position

    xxxxx C:\Blablah.txt xxxxx
          ABCDEFGHIHKLMNO
    

    Then :

    • If you right-click in the first line, on the context menu option Open File, with caret on positions C to K, it opens C:\Blablah.txt file in Notepad++

    • If you right-click, in the first line, on the context menu option Open File, with caret on positions A,B, L, M, N or O , you get the error message The file you’re trying to open doesn’t exist.

    Now, if the filename ends the line, as below :

    xxxxx C:\Blablah.txt
          ABCDEFGHIHKLMNO
    

    Then, it’s a bit different :

    • If you right-click in the first line, on the context menu option Open File, with caret on positions C to O, it opens C:\Blablah.txt file in Notepad++

    • If you right-click, in the first line, on the context menu option Open File, with caret on positions A or B , you get the error message The file you’re trying to open doesn’t exist.


    Now, a radical way to select a valid full pathname without bothering about caret location, would be :

    • Go to Settings < Preferences > Delimiter > Word character list

    • Select the option Add your character as part of word

    • Type in the 3 characters .\: in the field

    • Close the Preferences dialog

    From now on, a right-click at any location of a valid pathname OR a double-click on any part of it, followed with the choice of the Open file option, should open this file in Notepad++

    Best Regards,

    guy038



  • @Andy-Klaj said:

    Can someone help me to allow for content liek ‘File2.txt’ to be recognized as a file in the current directory in Notepad++ ?

    What is your definition of “the current directory in Notepad++”?



  • @guy038 's posting hints that Open File is a not-real-smart feature. Many files these days have spaces in them, their names I mean of course. How is THAT going to work with this feature? Likely not too well.



  • Open File is a not-real-smart feature

    Indeed. A little birdie once told me that there’s someone working on a PythonScript improvement of the open-file-under-cursor, which I beta tested. When I’m home, I’ll have to look through my test cases to see if the local-directory-file was covered; if it is, I may put in a request for accelerated release (and point that someone to this thread); if it’s not in there, I may add a feature request. (No, I do not have permission to publish it for that someone.)



  • Hello, @ady-klaj, @alan-kilborn, @peterjones and All,

    Really, I’m unforgivable ! I should have tested a file name or a folder name containing spaces, too ;-)) For instance :

    xxxxx C:\Bla blah.txt xxxxx
    

    In that case, it’s even worse ! Whatever the location of the caret, in the full pathname, it does not work :-((

    Finally, the correct way, in all cases, is to select all the pathname C:\bla blah.txt and right-click on the Open File option

    Actually, the context menu option should been named : Open Selected Pathname or File ;-))


    Now, it would be hard to find a correct algorithm to get a pathname or file selected, only from current position of caret !

    Indeed, let’s suppose the line, below, in a file, with rubbish xxxxx text and caret located between letters e and s of the test word

    xxxxx Small test.txt xxxxx
    

    And let’s suppose that a file name, with its extension, should contain word characters, dots or spaces ( very basic rule ! )

    Well, even if you scan text rightwards and leftwards, how to decide if the file name is :

    • Small test.txt

    • xxxxx Small test.txt xxxxx

    as you’ve included spaces as valid characters in filenames ?

    So, all in all, the fact of selecting pathname/filename, before a right-click on the context menu option Open File, seems rather pertinent !

    Cheers,

    guy038


Log in to reply