how to remove trailing spaces from selected text in PyCharm

I have the following python code, where the previous developer left random spaces at the end of each line within the triple quoted string. 

I would like to be able to select lines 2 thru 10 below and be able to invoke an action on demand (select it from a menu, keyboard short cut, etc.) to remove all trailing white space from the selected lines, regardless if the line is part of a string or if it is part of some code.

I've seen the posts about remove trailing spaces on save, but that will not remove spaces from inside of triple quoted strings.

df = spark.sql(
    """ 
    select 
        col1, 
        col2, 
        ... 
    from my_table 
    where col1 = 'value 1' 
    and col2 = 'value 2' 
    and ... 
    """
)
0
1 comment

Unfortunately, formatting SQL with triple quotes inside is  an old feature request as mentioned here - https://youtrack.jetbrains.com/issue/PY-32711/SQL-Reformat-in-Python

0

Please sign in to leave a comment.