Option to close all without saving + open in read only from FTP



  • Hi,
    Is there a way or plugin for:

    1. close all files without saving? - I usually have many tabs open with code snippets just for current keep. When I want to close all I have to click on the save/don’t save alert for each.
    2. Open file from filezilla as read only? - Sometimes I want to open a file from the server just for reference. Many times it has the same name as the file I edit right now, so it is susceptible to edit without meaning to.

    Thanks.
    Yehuda



  • @yehudaTiram
    For 2, maybe the Edit->Set Read-Only command would help you?



  • @Jim-Dailey Thank you for the tip, but I am aware of that.
    I want to right click in filezilla and have read only. But thinking again’ that have actually nothing to do with NPP.



  • @yehudaTiram ,

    Filezilla > Edit > Settings > File Editing: ☑ Use Custom Editor: "C:\Program Files (x86)\Notepad++\notepad++.exe" -ro

    I just had to add the -ro to the command line, because NPP was already my custom editor: I verified that RClick > View/Edit opened as Read Only in my existing NPP instance. (And it left my other open documents as writeable.)



  • @PeterJones Thank you for taking the time and for the info. I was not aware of that switch.
    However, I don’t want all the files to to be read only. I want only selected downloads. That is why I thought of a right click.
    Thanks,
    Yehuda



  • Sorry, I get to the View/Edit option in FileZilla by right clicking on the file in the remote pane, so I thought that’s what you meant.

    If you want a second option in the FZ Right Click menu, you’ll either have to find a way to customize that menu (I didn’t find it in a quick search), or ask the FZ team to add either a right-click customization feature or ask for a second “read-only” option in the right-click menu, with a separate “read-only custom editor” blank in the settings.

    But you’re right: there’s no way to directly tell NPP that you want to open the file read-only sometimes and read-write other times, without FileZilla being the one to tell NPP about that.

    (Well, I guess that’s not exactly true: you could write/get a wrapper script that you set as the custom “editor” in FZ, and that script could ask you for every file, whether you want read-only or read-write access to the selected file, and have the script then call NPP with the appropriate option… Hmm, that seems like a fun challenge; if you’re patient, and not the type to have already written your own script, you might find such a script magically appear here sometime in the next few days.)



  • It’s really nice of you to take that challenge.
    Another option that occurred to me while reading your post is that maybe it is possible to do that if I use an ftp plugin that is installed in NPP. I mean, opening (ftp) read only files from that plugin while keep working with FZ for the rest. This sounds like a solution to me if there is a plugin that can provide that feature. I’ll check it out.
    As for the magically appeared script I wonder if the logic can stand. After all, even if you get FZ to open the file and prevent it from saving (which may be acceptable in some conditions) NPP will still try to save the file, isn’t it?



  • Maybe a good start will be with NppFTP plugin.



  • I also like the idea of using NppFTP. However, I would make FileZilla always call the Read Only version (notepad++ -ro), and use NppFTP for the files you want to edit, because NppFTP is more setup up for editing remote files, not just viewing them (I don’t see a ReadOnly option in NppFTP).

    If you want to try the script to ask every time:

    1. Save the following code as npp-ro.vbs in a known location.

      • Change the npp = """...""" line to point to your notepad++.exe: mine was in the default 32bit install location
      • Make sure it still uses the three quotes (""") on each end, because that passes the quotes to the command processor, in case there are spaces in your path to NPP
    2. Set FileZilla Custom Editor = c:\windows\system32\wscript.exe "C:\path\to\scripts\npp-ro.vbs"

      • If you have strange path to wscript.exe, you’ll have to change that path, too

      dim strFullPath, rv, cmd, npp
      strFullPath = Wscript.Arguments(0)
      npp = “”“C:\Program Files (x86)\Notepad++\notepad++”""
      rv = MsgBox(“Should I open '”+strFullPath+"’ as ReadOnly?" + vbNewLine + vbNewLine _
      + " * YES = ReadOnly" + vbNewLine _
      + " * NO = Read-Write" + vbNewLine _
      + " * CANCEL = Don’t Open" + vbNewLine, _
      vbYesNoCancel + vbQuestion, _
      “NPP ReadOnly Filter”)
      if vbCancel = rv then WScript.Quit
      if vbYes = rv then npp = npp + " -ro"
      cmd = npp + " “”" + strFullPath + “”" "

      ’ use run(cmd,0) to not clutter screen or task bar
      dim WshShell, retval
      Set WshShell = WScript.CreateObject(“WScript.Shell”)
      retval = WshShell.Run(cmd, 0, false) ’ false == do not wait for command to finish
      set WshShell = Nothing



  • @PeterJones That’s really cool. It works magically :)
    Thank you for taking the time.
    I use it now and it seems like a good way to go.
    Yehuda


Log in to reply