Sublime Text 2 adds extra line breaks. How to solve? - sublimetext2

When I open certain files through FTP with Sublime Text 2, such as .css or .php files, ST2 adds an extra line break after every line. The result is a lot of unnecessary white space that make the files difficult to scan and clean up again.
Can someone please instruct me how to set the preferences to where no extra line breaks are added when I open my files?
Much appreciated.

Go to Settings - Default and find this option -
// Set to true to ensure the last line of the file ends in a newline
// character when saving
"ensure_newline_at_eof_on_save": false,

Related

Setting tab size/ space size as default in VSCode

I'm currently using VSCode and I have this problem. I want to set the space size equals to 1 and tab size equals to 2 as default for every project. But it still set back as spaces: 4 for every project.
And as I set the spaces = 2, and run Beautify file. Everything looks good with space = 2. Then I hit save it format my file to indent size 4. How do I set it as default equal to 2 guys?
even I change in User settings
By default VSCode try to detect indent option for a file. So set editor.detectIndentation to false
// When opening a file, `editor.tabSize` and `editor.insertSpaces` will be detected based on the file contents.
"editor.detectIndentation": false,
EditorConfig is a handy standard for establishing project wide formatting options: http://editorconfig.org.
There's a VSCode extension supporting it: https://github.com/editorconfig/editorconfig-vscode
This doesn't directly answer your question, but it works well. And if you switch editors, you still can keep your formatting standard by getting each editor's plug-in for EditorConfig.

Sublime auto fold the code

By default when I open file it looks as follows:
And I want always unfold when I open a file
Is there any keybinding exist that can unfold everything automatically not require any command from keyboar ? Thank you !
If you last saved a file while it was folded, Sublime will remember that. Select Edit -> Code Folding -> Unfold All, make a small change like adding then deleting a space, then resave the file. It will open unfolded next time.
Also, as a point of style, please use 4 spaces for indentation. Using 1 space, it's almost impossible to differentiate the various indentation levels. 2 spaces is almost as bad. With a Python file open, select Preferences -> Settings-More -> Syntax-Specific - User and add the following:
{
"tab_size": 4,
"translate_tabs_to_spaces": true
}

Sublime Text 2 highlighting always disabled on trailing spaces plugin

In Sublime Text 2 I have installed the trailing spaces plugin, however the highlighting is always set to disabled.
if I toggle the highlight regions, by doing the following:
edit -> trailing spaces -> highlight regions
I always get the following:
highlighting of trailing spaces is disabled!
I have restarted sublime since the package install, but the toggle doesn't seem to work, does anyone know how to fix this issue?
Work around fix - not the solution to the problem
As for others it seems, i couldn't seem to get this trailing spaces to highlight no matter what i did, so what i did was remove the trailing spaces automatically on save. Not ideal but used to it now, works nicely.
Go to SublimeText 2 > Preferences > User Settings (or just hit the Mac Standard cmd + ,). This should open your User Settings as a JSON file. Add the following to your file
"trim_trailing_white_space_on_save": true
That's it. You're good to go.
I had this problem in Sublime Text 3.
I fixed it by deleting my trailing_spaces.sublime-settings file in the Sublime Text user package settings folder (which for me was %APPDATA%\Sublime Text 3\Packages\User) and reinstalling the plugin.
Some more discussion about this issue can be found on the plugin GitHub page here.
It's a known bug - see their Issues page on GitHub.
I was able to get it working by starting Sublime with a non-blank string value for the setting trailing_spaces_highlight_color
Open Preferences > Package Settings > Trailing Spaces > Settings - User
Replace:
"trailing_spaces_highlight_color": ""
With:
"trailing_spaces_highlight_color": "invalid"
Restart Sublime.
Edit > Trailing Spaces > Highlight Regions should work as expected now.
If you restart Sublime, "trailing_spaces_highlight_color" must not be a blank string, otherwise it will stop working again. Repeat the steps above to fix.
As long as Sublime is started with a non-blank string value for trailing_spaces_highlight_color, the toggle highlight regions works.
It looks like the plugin is caching the value in the setting file when Sublime loads. If you make changes to the settings file and toggle highlighting, the original value is restored. Which is why you need to restart Sublime for setting changes to take effect.

Sublime Text 2 tab_size setting not correctly activated

I have the following in my user/Preferences.sublime-settings
{
"tab_size": 2,
}
And most of the time it works. But once in a while I open a ruby file, and it jumped back to 4 spaces. I'm wondering if there is some bug or slight difference in opening a file that could change this?
Having trouble tracking this down. Thanks for the help.
You'll want to add:
"detect_indentation": false
This is on by default and ST is trying to be smart detecting the indentation of your current file, overloading the user or syntax specific default.
Here are various Sublime Text 2 tab settings explained:
http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/#Configure_sane_tab_and_whitespace_policy_and_other_settings
Note that the tab setting may be per file type
There is also autodetect from file enabled by default and your source code file may contain bad tabbing

How to get JSHint smarttabs option working in Sublime Text 2

I can't seem to get the Sublime Text 2 SublimeLinter package to stop showing the "Mixed tabs and spaces" warning.
I've set "smarttabs" : true in the settings, but it's still not taking.
Has anyone else solved this problem yet?
Here's my user settings for the SublimeLinter package: https://gist.github.com/3737558
Thanks.
I solve the problem like this.
First do not use mix tabs and spaces in the files. Use spaces only. Sublime can finely handle the indentation without a hard tab character.
Setup Sublime Text 2 to use spaces only:
// Tab and whitespace handling.
// Indent using spaces, 4 spaces ber indent by default, clean up extra whitespaces on save
"tab_size": 4,
"translate_tabs_to_spaces": true,
"trim_automatic_white_space": true,
"trim_trailing_white_space_on_save": true,
// Do not try to detect the tab size from the opened file
"detect_indentation" : false,
If you encounter any old files with mixed tabs and spaces you can convert them to spaces only from View > Indentation > Convert tabs to spaces menu.
Why tab character is bad in your source code
http://opensourcehacker.com/2012/05/13/never-use-hard-tabs/
i have the same problem, maybe i found the reason
the smarttabsoptions can control the warning when space after tab, but can't control the warning tabs after the space, you can try it
if you want to disable the warning you can add a comment at top top of the file
/*jshint -W099*/