Community
    • 登入

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

    已排程 已置頂 已鎖定 已移動 General Discussion
    10 貼文 3 Posters 5.9k 瀏覽
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • yehudaTiramY
      yehudaTiram
      最後由 編輯

      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 條回覆 最後回覆 回覆 引用 0
      • Jim DaileyJ
        Jim Dailey
        最後由 編輯

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

        1 條回覆 最後回覆 回覆 引用 0
        • yehudaTiramY
          yehudaTiram
          最後由 yehudaTiram 編輯

          @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 條回覆 最後回覆 回覆 引用 0
          • PeterJonesP
            PeterJones
            最後由 PeterJones 編輯

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

            yehudaTiramY 1 條回覆 最後回覆 回覆 引用 0
            • yehudaTiramY
              yehudaTiram @PeterJones
              最後由 編輯

              @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 條回覆 最後回覆 回覆 引用 0
              • PeterJonesP
                PeterJones
                最後由 編輯

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

                yehudaTiramY 1 條回覆 最後回覆 回覆 引用 0
                • yehudaTiramY
                  yehudaTiram
                  最後由 編輯

                  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 條回覆 最後回覆 回覆 引用 0
                  • yehudaTiramY
                    yehudaTiram @PeterJones
                    最後由 編輯

                    Maybe a good start will be with NppFTP plugin.

                    1 條回覆 最後回覆 回覆 引用 0
                    • PeterJonesP
                      PeterJones
                      最後由 PeterJones 編輯

                      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

                      yehudaTiramY 1 條回覆 最後回覆 回覆 引用 0
                      • yehudaTiramY
                        yehudaTiram @PeterJones
                        最後由 編輯

                        @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 條回覆 最後回覆 回覆 引用 0
                        • 第一個貼文
                          最後的貼文
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors