Sublime Text 2 doesn't have the same indent as Notepad++ - sublimetext2

I just moved from Geany to Sublime Text. It has a lot of pleasant features but I just can't get used to the indentation. I used Geany mainly because I could configure the indentation level exactly like it was on Notepad++ (Auto indent mode : Basic).
For example:
<element>
<element>ENTER
indent here
On Sublime text:
<element>
<element>ENTER
indent here
I would like to know how to have the same indentation as Geany (Mode Basic) and Notepad++.
In my config file on Sublime Text I added:
"auto_indent": true,
"smart_indent": false
which is not enough.

The indent is controlled by the chosen syntax. I get the described behaviour when I choose the XML Syntax on Sublime Text 3 (3065, Mac).
Try another syntax like HTML, and you should get the indent you want.

Related

Sublime Text 2 + Emmet - Expansion doesn't work

I have the Emmet Plugin on Sublime Text 2, and for example, in a CSS file, pressing TAB after:
pos:r
should result in
position:relative
But instead, after the :, the fuzzy search changes completely and disregards whatever was before the :.
This is very similar to this question:
Sublime Text 2 + Emmet - not expanding correctly
, but I have tried adding "disable_tab_abbreviations_on_auto_complete": false in valid JSON format, saved, restarted ST2, but the behaviour is still the same.
Try a couple of things here. They fixed the problem for me:
Save the file in ".css" format
After typing pos:r press Ctrl (Cmd) + E
Hope this helps.

How do I make custom snippets for Sublime Text 2 that use the same indentation as the current file?

Different projects can use different indentation styles (2-4 spaces, tabs) and I want my custom snippets to follow the style of the current file. The built-in Ruby snippets does this but my custom snippets retain the indentation of the snippet. I checked the docs and found the predefined variables:
$TM_SOFT_TABS YES if translate_tabs_to_spaces is true, otherwise NO.
$TM_TAB_SIZE Spaces per-tab (controlled by the tab_size option).
But I can't really see how to make use of those to control which indents to use.
Just use the tab character for indents in snippet files. Sublime Text will automatically convert them to the correct indentation style for the current file.

How to configure Sublime text to support both spaces and tabs for indentation

I am using Sublime Text for JavaScript development where I use tabs for indentation.
But, for Python development, I need to use spaces (per PEP-8). So what config directives should I change to support both.
(I am fairly new to Sublime Text)
You can create syntax specific configurations. Preferences -> Settings - More ->Syntax Specific - User. Add the following configuration "translate_tabs_to_spaces": false, setting the boolean as appropriate.

Is there a increaseIndentPattern in Sublime Text?

I'm trying to add auto increate indentation feature in a Sublime Text package.
As for TextMate, there's increaseIndentPattern = '\{'; that can make easy indentation.
http://manual.macromates.com/en/appendix#indentation_rules
How can I do that in SUblime Text?
Sublime Text 2 already has easy indentation built in.
Hit Ctrl+] to indent right, and Ctrl+[ to indent back or remove indentation.
Similarly, you can select the text you want to indent, and hit the Tab key. This indents the selected block of text. Shift+Tab will remove indentation of selected text.
If you are working with predefined syntaxes you can define a keybinding for your "ReIndent" command, which will execute Edit>Line>Reindent command on the entire document.
However, if you reeeeally want to get your hands dirty with setting up how the program indents specific language syntaxes, you go to the Preferences Menu and hit Browse Packages.
Look for the language you want to modify indentation rules for, I'll use PHP as an example. There are 2 files that have indentation rules for my copy of PHP right now. Their names are as follows:
Indentation Rules Annex.tmPreferences
Indentation Rules.tmPreferences
There should be another copy of these same filenames with *.cache at the end. Feel free to add .old after .cache and modify the plain *.tmPreferences ones.

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*/