1

I have a really lot of files where I have to modify them manually. Pattern for modify is: always start's from line ~450 where I have to add some random data. For now I have to press "CTRL + G" on every active file in NP++ and write manually line where I like jump to but its not perfect solution for me.

So I'm wondering its possible somewhere in NP++ settings or specific file extension assignment in Windows registry to: open group of files by right click of them, select "Edit with Notepad++" and next be already at start on that line 450 on that every opened file?

What I know you can start app from x line but only for one file by creating shortcut like:

"C:\Program Files (x86)\Notepad++\notepad++.exe" c:\users\username\desktop\test.txt -n450

It would be best if something like this could be achieved:

enter image description here

but if this can be done with other method as well I really love to know about it.

3
  • As you have to type in each file anyway, just define a macro to go to (Ctrl+G) line 450, bind it to a shortcut (like Ctrl+Shift+F12), and type that key before typing the rest. Commented Jun 14 at 16:21
  • What kind of modification do you have to do? Are you inserting same lines in all files, for example? Commented Jun 14 at 16:26
  • Its a random data unfortunately. I can only automate it a little by get to starting point what is line 450 in every file. Commented Jun 16 at 19:55

2 Answers 2

3

From the Command prompt page of the Notepad++ User manual. The -ncommand line argument is defined as "Scroll to indicated line (LineNumber) on filepath.".

One solution is to create a batch file (i.e. a *.bat file) containing notepad++ -n450 %* (it might need to contain the full path of the Notepad++ executable, depending on the PATH environment value of the computer). Having this batch file on the Windows desktop allows file to be dragged from file explorer onto the batch file and then Notepad++ will process those files.

Another solution is to create a batch file with one line per file to be processed (for example by running something like dir *.txt > mybatchfile.bat a Command Window, then edit the file to (1) remove unwanted files and (2) prefix every line with notepad++ -n450 . If file names contain spaces then they need to be wrapped in double quotes, so they look similar to notepad++ -n450 "file the first.txt".

Sign up to request clarification or add additional context in comments.

1 Comment

1st solution is much more easier for me. I created file: "C:\NP++from450line.bat" with body: "C:\Program Files\Notepad++\notepad++.exe" -n450 %*. Now I have to drag selected files what I need (from search or pickup) and drop them to this bat file. Thank you :)
1

With good hint from AdrianHHH's answer
I find a almost best way what I need when originally asked question.

Now I have this option enabled for this example file extension:
enter image description here

So basically its can be done with modify registry key:

"HKEY_CLASSES_ROOT\SystemFileAssociations\[.YourExtension]"

with add command for 'batch-edit'.

I share ready example for add context menu to .ps1 file context menu. Just copy this bellow, paste to any editor and save it as reg file - eg. :"C:\NP++l450.reg".


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\Edit with Notepad++ from line 450\Command]
@="\"C:\\Program Files\\Notepad++\\notepad++.exe\" \"%1\" -n450 %*"

[HKEY_CLASSES_ROOT\SystemFileAssociations\.ps1\Shell\Edit with Notepad++ from line 450]
"Icon"="C:\\Program Files\\Notepad++\\notepad++.exe"

Next just run this reg file and next new entry Context Menu shall appear for any PS1 file.

  • Its now works for all/any selected ps1 files what I like to batch edit.

  • This solution is only for one extension (ps1), but also works for other extensions if you modify them in registry key:

    "HKEY_CLASSES_ROOT\SystemFileAssociations\[.YourExtension]"

  • If you did modify of .ps1, .psm1 extensions in registry and next select only that type of files, then this option will be visible, but it you add to them also not modified extension like .psd1, then context menu will be not show at all.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.