I want to add a character at the beginning (or at the end) of each line in the open document. In the "Find what" field of the Replace dialog box, I specify '^' (without quotes) for beginning of line (or '$' for end of line); when I click Replace all, the error message "The regular expression to search is formed badly" pops up. As far as I know, this is a valid regular expression, which works in other text editors, such as PSPad.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you do this using the CTRL+R Find/Replace dialog, it works fine, except on empty lines. (The regexp part (.) requires at least one character to be on the line. You can additionally replace the empty lines using another Replace action.)
Using this regexp with the CTRL+H Replace dialog, has the same effect when you use the "Replace all" button. However, when you press "Replace" sequentially, you'll notice the character will be inserted at the beginning of the same line over and over again. Unfortunately, the cursor position doesn't move because of the auto-selection of the replaced string.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to insert some characters before a list of variable names.
Find field:
^\t
Replace field:
\t@S_
After finding and replacing the first occurrence, the "found" selection doesn't move to the next line. Instead, replacing will be done on the same line over and over again, inserting the same characters at the same position over and over again. The cursor should definitely have moved to the end of the found and replaced selection, so the replaced occurence wouldn't be considered again.
Luckily, I didn't press Replace All!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can also use the advanced search/replace (control+r) without regex. Use control+M to place a newline in the search box, then control+M followed by the text you want to add.
This won't work for the first line.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I agree that this behavior should work anywhere regular expression replacement is supported. A regular expression can certainly match zero characters - I'm not sure if Notepad++ supports some of the more advanced options like lookbehind and lookahead but the simple cases ^, $, and ^$ should just work like they do in just about every other editor that supports regular expression search/replace.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I want to add a character at the beginning (or at the end) of each line in the open document. In the "Find what" field of the Replace dialog box, I specify '^' (without quotes) for beginning of line (or '$' for end of line); when I click Replace all, the error message "The regular expression to search is formed badly" pops up. As far as I know, this is a valid regular expression, which works in other text editors, such as PSPad.
This regexp only specifies _where_ you look for something, but not for what.
Try something like ^(.) and replace this by @\1 where you replace @ by that character you want to add.
If you do this using the CTRL+R Find/Replace dialog, it works fine, except on empty lines. (The regexp part (.) requires at least one character to be on the line. You can additionally replace the empty lines using another Replace action.)
Using this regexp with the CTRL+H Replace dialog, has the same effect when you use the "Replace all" button. However, when you press "Replace" sequentially, you'll notice the character will be inserted at the beginning of the same line over and over again. Unfortunately, the cursor position doesn't move because of the auto-selection of the replaced string.
I'm having the same problem with CTRL+H.
I want to insert some characters before a list of variable names.
Find field:
^\t
Replace field:
\t@S_
After finding and replacing the first occurrence, the "found" selection doesn't move to the next line. Instead, replacing will be done on the same line over and over again, inserting the same characters at the same position over and over again. The cursor should definitely have moved to the end of the found and replaced selection, so the replaced occurence wouldn't be considered again.
Luckily, I didn't press Replace All!
You can also use the advanced search/replace (control+r) without regex. Use control+M to place a newline in the search box, then control+M followed by the text you want to add.
This won't work for the first line.
Has any work been done of this bug, I am experiencing the same issue with 5.6.8
Using TextFX's Ctrl-R as suggested earlier, you can check the "1 per line" box to force this behaviour.
CChris
I agree that this behavior should work anywhere regular expression replacement is supported. A regular expression can certainly match zero characters - I'm not sure if Notepad++ supports some of the more advanced options like lookbehind and lookahead but the simple cases ^, $, and ^$ should just work like they do in just about every other editor that supports regular expression search/replace.
N++, or rather Scintilla, doesn't have all the Perl goodies.
I had posted apatch allowing zero length regular expressions starting in ^ or ending in $ to be processed. Hope it makes it to released code some day.
CChris
cchris,
Where can we find your patch?
On the Trackers menu on this page, select Patches, and you'll find the patch fairly easily then.
CChris