Reduce Some Typos
-
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 -
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:
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:
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 anEdit with Notepad++
that is similar but without the-ro
command line argument. -
@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.
-
@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”
-
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.