• Login
Community
  • Login

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

Scheduled Pinned Locked Moved General Discussion
10 Posts 3 Posters 5.6k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y
    yehudaTiram
    last edited by Oct 27, 2016, 1:33 PM

    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

    1 Reply Last reply Reply Quote 0
    • J
      Jim Dailey
      last edited by Oct 27, 2016, 2:08 PM

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

      1 Reply Last reply Reply Quote 0
      • Y
        yehudaTiram
        last edited by yehudaTiram Oct 27, 2016, 2:57 PM Oct 27, 2016, 2:56 PM

        @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.

        1 Reply Last reply Reply Quote 0
        • P
          PeterJones
          last edited by PeterJones Oct 27, 2016, 7:06 PM Oct 27, 2016, 7:05 PM

          @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.)

          Y 1 Reply Last reply Oct 28, 2016, 8:56 AM Reply Quote 0
          • Y
            yehudaTiram @PeterJones
            last edited by Oct 28, 2016, 8:56 AM

            @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

            1 Reply Last reply Reply Quote 0
            • P
              PeterJones
              last edited by Oct 28, 2016, 1:32 PM

              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.)

              Y 1 Reply Last reply Oct 28, 2016, 6:22 PM Reply Quote 0
              • Y
                yehudaTiram
                last edited by Oct 28, 2016, 4:06 PM

                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?

                1 Reply Last reply Reply Quote 0
                • Y
                  yehudaTiram @PeterJones
                  last edited by Oct 28, 2016, 6:22 PM

                  Maybe a good start will be with NppFTP plugin.

                  1 Reply Last reply Reply Quote 0
                  • P
                    PeterJones
                    last edited by PeterJones Oct 28, 2016, 8:30 PM Oct 28, 2016, 8:29 PM

                    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

                    Y 1 Reply Last reply Oct 29, 2016, 8:16 AM Reply Quote 0
                    • Y
                      yehudaTiram @PeterJones
                      last edited by Oct 29, 2016, 8:16 AM

                      @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

                      1 Reply Last reply Reply Quote 0
                      5 out of 10
                      • First post
                        5/10
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors