PEP8: conflict between W292 and W391
W391 is a blank line, that is, two consecutive \ns. There is no conflict.
W391 is a blank line, that is, two consecutive \ns. There is no conflict.
sed -i ‘/^$/d’ foo This tells sed to delete every line matching the regex ^$ i.e. every empty line. The -i flag edits the file in-place, if your sed doesn’t support that you can write the output to a temporary file and replace the original: sed ‘/^$/d’ foo > foo.tmp mv foo.tmp foo If you … Read more
Your pattern seems alright, you just need to include the multiline modifier m, so that ^ and $ match line beginnings and endings as well: /^\s*\n/gm Without the m, the anchors only match string-beginnings and endings. Note that you miss out on UNIX-style line endings (only \r). This would help in that case: /^\s*[\r\n]/gm Also … Read more
Press Ctrl+H (Replace) Select Extended from SearchMode Put \r\n\r\n in Find What Put \r\n in ReplaceWith Click on Replace All
Use String.trim() method to get rid of whitespaces (spaces, new lines etc.) from the beginning and end of the string. String trimmedString = myString.trim();
For those who might be interested – what worked for me in version 1.3.1 (and still works in 1.33.1) to delete blank lines I used ctrl+h (find and replace) alt+r (Use regular expression) In find box then: \n\n In replace box: \n This should make two consecutive end of line signs into one. edited: If … Read more