Sublime Forum

Adding a newline after commas

#1

Short Version:
Is there a simple way to have a command to add a newline after every comma in my code?

Longer:
Use case: I am copying pseudocode from another source and pasting it in to Sublime Text to more easily edit and format it - then pasting the formatted and edited code back to the source. When first pasted in to ST it is just a very long single line of code. I was using CodeFormatter to format it, and it was almost a perfect solution. However, the newline after brackets which creates whitespace (ie, {Test Value} being converted to { Test Value }) makes this unusable, as the value with spaces injected is invalid.

So instead of using CodeFormatter, a simple solution of newlines after commas instead of around brackets would do ok for now.

0 Likes

#2

If you select a comma and press ctrl+d (multiple times) or alt+f3 you can select all commas and then insert a newline behind them.

0 Likes