sublime-better-coffeescript icon indicating copy to clipboard operation
sublime-better-coffeescript copied to clipboard

does it support format coffeescript

Open enginespot opened this issue 12 years ago • 9 comments

so currently I want to use sublime-better-coffeescript format coffeescript code , so does it support?

enginespot avatar Jun 07 '13 13:06 enginespot

You mean auto indenting and such? It doesn't have that option as it is highly difficult to tell what the scope is in the written text. It is like writing 1000 words without any punctuation and line break and trying to tell where the sentences end and paragraphs begin.

However:

  • if you are talking about eliminating trailing spaces there is another sublime plugin for that https://github.com/SublimeText/TrailingSpaces
  • If you are talking about converting tabs to spaces, then sublime can do that with a click.
  • if you want to convert javascript to coffeescript, js2coffee can convert into a nicely formatted coffeescript.

Does this help? :)

aponxi avatar Jun 07 '13 16:06 aponxi

hmm... how to say, for examply , currently I am using webstorm , when I write coffeescript code , it can format my coffeescript code by the command "Code--> Reformat Code" then the code style of coffeescript will be better

for http://jsbeautifier.org/ it can change js to a better style , so I think maybe Coffeescript can also change to a better style

enginespot avatar Jun 07 '13 16:06 enginespot

Well look at this answer on Stack Overflow:

CoffeeScript code that runs properly should already be "beautiful", since most of it's characteristics are not optional.

If it runs, then it has proper indentation. Any other beauties can be indentations with tabs, with 2 spaces, 4 spaces, additional line breaks after a line break (after functions maybe) and spaces after a comma if there is none.

If that is what you are looking for, just tidying up, then it is a rather simple enhancement to make. And I will write it down in the to-do list.

Is that what you are looking for? If not please tell me what webstorm does when you reformat code.

aponxi avatar Jun 07 '13 16:06 aponxi

it is not long word to description, so I put screenshot of webstorm , hope it helps 1 2 3 4

http://www.jetbrains.com/webstorm/webhelp/coffeescript-support.html

enginespot avatar Jun 07 '13 17:06 enginespot

Okay! Thank you for the screenshots!

I will add this feature!

aponxi avatar Jun 07 '13 17:06 aponxi

May be useful: https://github.com/derekchiang/Coffee-Formatter https://github.com/derekchiang/Sublime-CoffeeScript-Formatter

lavrton avatar Jun 17 '13 01:06 lavrton

Hi lavrton I have tried above tools, but it does not work well.

enginespot avatar Jun 20 '13 17:06 enginespot

I think what @enginespot is describing is the case where you copy and paste some coffeescript from another source which is indented with 2 spaces (or a 2 space tab) but you want 4 spaces (or a 4 space tab). I've run into this same issue many times, and it is annoying because Sublime Text's indentation options don't correct this.

However, the Indentation: Reindent Lines command does attempt to apply the desired correction, and sometimes it succeeds.

zakdances avatar Oct 19 '13 00:10 zakdances

I think there are only two ways to implement this.

  1. Someone should create own nodejs package for coffee formating. Then use it simular to coffeescript compiler with some configuration.
  2. Wait until some IDE project will publish free formating tool for coffeescripts.

lavrton avatar Nov 16 '13 12:11 lavrton