• Login
Community
  • Login

Reduce Some Typos

Scheduled Pinned Locked Moved General Discussion
5 Posts 2 Posters 492 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.
  • E
    Eric Bloch
    last edited by Dec 9, 2021, 8:43 PM

    In the past I made typos by typing in the wrong document open for reference instead of the desired doc being modified. To reduce this I made the following batch to toggle the Windows 10 file read attribute on/off. Place batch in Windows “SendTo” folder.

    Note that NPP must be closed to change the attribute of a file open in NPP and line with START extends to 400.

    : _ReadAttribChange.bat
    :: Toggles file Attribute r on/off
    :: Use Right Click SendTo menu
    :: Up to 9 files at once
    ECHO OFF & CLS
    :: Change CMD Window title, size, and position
    :: ==================================
    TITLE .ReadAttribChange+.bat
    START “” /WAIT D:_NirSoft\multimonitortool-x64\MultiMonitorTool.exe /MoveWindow 1 Title “.ReadAttribChange+.bat” /WindowLeft 1200 /WindowTop 400
    MODE CON: COLS=11 LINES=1
    :: IF NOTEPAD RUNNING CLOSE IT
    :: ----------------------------------------------------------------
    TASKLIST | FIND “notepad++.exe” > NUL && (TASKKILL /IM “notepad++.exe” /T > NUL & SET “_Run=1”)
    TIMEOUT /T 1 > NUL
    FOR %%G IN (“%1” “%2” “%3” “%4” “%5” “%6” “%7” “%8” “%9”) DO (
    ECHO %%~aG > F:_ATTRIB.TXT
    FINDSTR “r R” F:_ATTRIB.TXT && ATTRIB -R %%G || ATTRIB +R %%G
    )
    DEL F:_ATTRIB.TXT
    :: IF NOTEPAD WAS RUNNING OPEN IT
    :: ----------------------------------------------------------------
    IF %_Run%==1 START “” “C:\Program Files\Notepad++\notepad++.exe”
    EXIT

    1 Reply Last reply Reply Quote 1
    • A
      Alan Kilborn
      last edited by Alan Kilborn Dec 9, 2021, 9:14 PM Dec 9, 2021, 9:12 PM

      A variation is to just tell Notepad++ that you want it to consider your file as not changeable. A way to do this on an already open file is via this menu item:

      9e30c60f-055b-4020-8749-a59347baa55a-image.png

      A command-line way to load files so that they aren’t changeable is:

      yourNppPath\notepad.exe -ro file1.ext file2.ext

      See the -ro part? That means “read-only” opening for any files that follow it, in the example two files.

      You can make it an Explorer right-click item (on Win10, works for me at least, YMMV) by using the command-line argument idea and creating the following key and value:

      a9eecd9c-d5db-4315-8aa3-12a6b91cd864-image.png

      Obviously, you’d need to replace yourNppPath where I show it above with your own path to Notepad++.

      Note in the registry I show what I have for View with Notepad++ but I also have an Edit with Notepad++ that is similar but without the -ro command line argument.

      E 1 Reply Last reply Dec 12, 2021, 8:08 PM Reply Quote 3
      • E
        Eric Bloch @Alan Kilborn
        last edited by Dec 12, 2021, 8:08 PM

        @alan-kilborn Thanks for your reply. I had not observed the ro selection on the right click menu which is very convenient for a single file. My batch is constructed to do up to 9 files at once and I have a second batch which toggles ro and adds the selected files to NPP.

        E 1 Reply Last reply Dec 16, 2021, 7:42 PM Reply Quote 0
        • E
          Eric Bloch @Eric Bloch
          last edited by Dec 16, 2021, 7:42 PM

          @eric-bloch
          Using “ro” only effects NPP and does NOT change the Window’s attribute.

          NPP should be changed from “Read Only” to “Set Read Only Flag” to match the “Clear Read Only Flag”

          A 1 Reply Last reply Dec 16, 2021, 7:57 PM Reply Quote 0
          • A
            Alan Kilborn @Eric Bloch
            last edited by Dec 16, 2021, 7:57 PM

            @eric-bloch

            There is perhaps an argument for additional functionality, specifically “Set Read Only Flag”, but I wouldn’t change or remove existing functionality if it were up to me.

            THIS THREAD may interest you, as it provides a means to add in the additional functionality.

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