Sublime Text 2: Trim trailing white space on demand

前端 未结 5 641
时光取名叫无心
时光取名叫无心 2020-12-22 18:45

I know that Sublime Text 2 can delete the trailing white space on files upon saving.

When working in a team and commiting a change to a file this tends to produce hu

5条回答
  •  旧时难觅i
    2020-12-22 19:00

    Here's a super simple way that uses no plugins or settings and works in most situations.

    1. Multi-Select and move cursor to the end of every line
    2. Hold CTRL-Shift, Press Left, Right
    3. The spaces and tabs at the end of the lines should now be selected. Press Delete or Backspace

      Note - Special characters such as ( and + may also be selected at the end of the line at this point, not just spaces.

    How to Multi-Select all lines:

    One way is to use the middle mouse key to select vertically then hit the End Key if it's a small selection.

    With hot-keys:

    1. CTRL-A (select all)
    2. CTRL-SHIFT-L (place cursor on all lines selected)
    3. END (Go to end of lines)

    You can also use the find function to find something that will be in every line, like the space character:

    1. \s (using regex)
    2. Click Find All
    3. Press the "End" key to get multiple cursors at the end of each line

    Sample Text:

    text and number     44  more text and a space  
    text and number 44  more text and 2 tabs        
    text and number 44  more text and no space or tab
    
    text and number 44  more text after a line feed
    

提交回复
热议问题