Remove empty lines in eclipse code editor by find/replace (Ctrl+F)

前端 未结 7 1117
轻奢々
轻奢々 2020-12-31 15:21

I want to remove all blank lines from my code by find/replace method in eclipse code editor.

I used regular expression \\n\\s*\\n to find all blank lin

7条回答
  •  情话喂你
    2020-12-31 16:22

    In response to the first part of your question about the incompatible line delimiter near index error, Eclipse seems to have an issue with Replacing the given line delimiter depending on the Text file encoding and New text file line delimiter settings.

    I had an issue where a Windows application mistakenly formatted UNIX-formatted source files, inserting CRLF wherever it saw fit. Because of the particular situation I had to replace all of the CRLF's with space. Eclipse wouldn't allow me to do this because of that error, but grabbing the preceding and succeeding characters did the trick:

    Find   : (.)\r\n(.)
    Replace: $1 $2
    

    Using wjans suggested answer:

    Find   : ^\s*\r?\n(.)
    Replace: $1
    

    I hope this helps with those of you still getting the incompatible line delimiter error.

提交回复
热议问题