Remove blank line in Eclipse

前端 未结 7 1550
梦毁少年i
梦毁少年i 2021-01-30 01:45

How can I remove lines that only contain spaces when using Eclipse Find/Replace prompt. I checked the \"Regular Expression\" check box, and tried the following, neither of whic

相关标签:
7条回答
  • 2021-01-30 02:11

    Many thanks to lamamac. In genereal, when you want to do search replace with regular expressions in eclipse the $ sign doesn't work as it should. Use '\s*\n' instead of '$'

    0 讨论(0)
  • 2021-01-30 02:12
    1. for the find/replace operation, "\n\r\s" regex will work on windows, for unix based system, "\n\s" can be used
    2. as already suggested, you can format your code by Ctl+Shift+F
    3. for manual work, locate a blank line and press Ctl+D (Cmd+D on Mac) <- gives u satisfaction of killing the line with your own bare hands :)

    cheer!

    0 讨论(0)
  • 2021-01-30 02:16

    This one worked for me for years:

    Replace this: [\t ]+$

    With nothing

    Hope this helps!

    0 讨论(0)
  • 2021-01-30 02:18

    As already suggested, regular expression and replacement is the solution, but such response would have been saving some minutes to me:

    1. click on ctrl+f
    2. use this replacement:

    0 讨论(0)
  • 2021-01-30 02:32

    Find: ^\s*\n

    Replace with: (empty)

    0 讨论(0)
  • 2021-01-30 02:32

    I was suprised that for XML files edited with Eclipse there is a good solution:

    • Select the checkbox value named 'Clear all blank lines' in Formatting panel Window->Preferences->XML->XML Files-> Editor

    • Save and use the "Ctrl+Shift+F' shortcut

    The blank lines will dissappear!

    0 讨论(0)
提交回复
热议问题