I have many text files, and I need to add some text (e.g. MNP) to the beginning of the first line in each file.
How can I do this in Notepad++?
(I'm using v6.6.9)
You can use regular expressions. Several places around the internet claim that the regex \A
works, but it wasn't working for me, it was cycling byte by byte through. I found that \A^
sticks to 0 position of the file.
Oddly, I additionally found that I couldn't replace \A
or \A^
and have it take effect. This is what worked for me.
Find: \A^(.*?)
Replace MNP\1
Truthfully, the \1 in Replace isn't even necessary since I'm cheating and basically telling notepad to look for 0 characters.
This should work just as well.
Find: \A^.*?
Replace MNP
Please backup your work beforehand though.
Alternatively, this also seems to work.
Find: .{0}(.*)
Replace: MNP\1
It effectively looks for 0 characters followed by the whole document/line (depending on whether . matches newline
is checked, this choice won't matter for the outcome however).