js-beautify-sublime icon indicating copy to clipboard operation
js-beautify-sublime copied to clipboard

Don't remove the last empty line when beautify

Open xieranmaya opened this issue 11 years ago • 9 comments

You know on github when your code do not have a newline an the end of file, github will notice you with "\ No newline at end of file" An example here: https://gist.github.com/xieranmaya/ca6727bf2165bfbdc240/revisions

And some people do have the habit of leave a newline at the end of file. Thank you!

xieranmaya avatar May 28 '14 07:05 xieranmaya

Add this to Sublime user preferences: "ensure_newline_at_eof_on_save": true.

argshook avatar May 28 '14 08:05 argshook

Thank you, I didn't find it in the default pref~~

xieranmaya avatar May 28 '14 08:05 xieranmaya

I'm sorry I've added this line but it have no effect~

xieranmaya avatar May 28 '14 08:05 xieranmaya

I'm using Sublime Text build 3059 on Linux and this options does work on my system. I'm not sure whether this options is Sublime 3 specific, but I guess it's not, so it should work on Sublime Text 2 as well.

Make sure you add this options into Preferences -> Settings - User. Double check for any syntax errors. You might, although unlikely, need to restart Sublime for this to take effect.

argshook avatar May 28 '14 08:05 argshook

I'm using Sublime Text 3 build 3059 on Windows 7. I restarted the sublime~~

xieranmaya avatar May 28 '14 08:05 xieranmaya

I don't think I can help any further, I just checked this option on Win 7, same 3059 build and it does work for me. Perhaps some installed package is somehow overriding this option? I'd suggest simply disabling packages one by one and check whether anything changed. You can easily enable/disable packages via command pallete (ctrl + shift + p). Just enter disable (or enable) and you'll see an option to do just that.

This doesn't seem to be an issue with js-beautify-sublime package, so I'd suggest closing it.

argshook avatar May 28 '14 08:05 argshook

I'll try it later~ thank you very much for helping!

xieranmaya avatar May 28 '14 08:05 xieranmaya

Hi,I've tried that, but it still not work in Win 7 and Win 8, 64 bit version. and, another word, your program will save my file with UTF-16 automaticly and github(both the default diff tool and the webpage do not recognise UTF-16 format file, instead it recognise it to binary file)do not show diff info in such files...

xieranmaya avatar May 29 '14 16:05 xieranmaya

I can confirm that adding the following line to Sublime Text 3 Preferences > Settings - User will fix this.

"ensure_newline_at_eof_on_save": true,

(note: this is a global sublime setting and not specific setting to this plugin)

pspi avatar Aug 28 '14 05:08 pspi