Home Download Buy Blog Forum Support

HTML tab indent problem

HTML tab indent problem

Postby WilsonPage on Sat Jan 14, 2012 4:43 pm

I have an annoying bug(?) in Sublime Text 2. When typing out an html closing tag and hitting return to knock it onto the next line Sublime Text doesn't maintain the correct tab indent. The tab indent is always one less than it should be.

I created a video demo here: http://www.youtube.com/watch?v=vDllGEdIupU

Any ideas why it is doing this, anyone experiencing similar issues?


Example image:

Image
WilsonPage
 
Posts: 2
Joined: Sat Jan 14, 2012 4:38 pm

Re: HTML tab indent problem

Postby ludder on Sat Jan 14, 2012 8:37 pm

I couldn't replicate this issue. However, I would recommend you to make use of Zen Coding or the tab completion feature (added in build 2165). A Sublime user should not have to type closing tags. ;)
ludder
 
Posts: 15
Joined: Tue Nov 29, 2011 9:44 pm

solved

Postby philosopherdog on Sat Jan 14, 2012 10:04 pm

Ok. I think I figured out what's causing the problem. I was having the same issue. Remove the html5 package. It's the culprit. Perhaps you could report this to the author of the plugin. Remove it through the package control and restart. In my case there was a file still left under the user area of the packages directory. Once I killed it the indent glitch disappeared.
philosopherdog
 
Posts: 35
Joined: Sat Nov 26, 2011 3:08 pm

Re: HTML tab indent problem

Postby WilsonPage on Sun Jan 15, 2012 7:10 pm

Yeeeeeeeeeah!!

Thank you so much. Ditched the HTML5 package, restarted, voila!

Problem fixed.
WilsonPage
 
Posts: 2
Joined: Sat Jan 14, 2012 4:38 pm

Re: HTML tab indent problem

Postby philosopherdog on Tue Jan 17, 2012 2:54 am

No worries. I was having the same problem and it wasn't happening on the usb key install. So I figured it must be a package causing the problem. It was very annoying.
philosopherdog
 
Posts: 35
Joined: Sat Nov 26, 2011 3:08 pm

Re: HTML tab indent problem

Postby amdtek on Thu Jan 19, 2012 5:14 am

Guys, I'm having a similar problem. To start with, let me tell you I'm using the 2165 build.

My issue has to do with pressing the *tab* keyboard-button to make the zen coding work. Say if I simply type in
Code: Select all
html then followed by tab
the zen coding won't work. Normally, it's supposed to give me this when "html"+*tab* is pressed -
Code: Select all
<html>
<head>
   <title></title>
</head>
<body>

</body>
</html>

But weird enough I'd admit it that it works randomly though should I press the tab twice or thrice. The count to press the tab key isn't fixed as sometimes pressing tab key once - it works, or most of the times pressing the zen coding effect would be rendered only after having pressed the tab key twice.

I'm wondering if that's rather being caused due to some conflict? I've installed zen coding through winbond's package but now I am reading on this post that
ludder wrote:...Zen Coding or the tab completion feature (added in build 2165)...


So could it be just that the 2165 build already comes with its own zen coding plugins and hence by installing another copy, manually through winbond's package - this could be causing this conflict?

In earlier builds, this wasn't really a problem. So maybe conversely there's actually a bug (that's yet to be identified and fixed) in this current 2165 build?
amdtek
 
Posts: 3
Joined: Sun Aug 28, 2011 8:55 am

Re: HTML tab indent problem

Postby philosopherdog on Thu Jan 19, 2012 1:17 pm

Try disabling the packages using the package disable feature and see if that solves the issue. If you have the html5 package installed that's probably the issue.
philosopherdog
 
Posts: 35
Joined: Sat Nov 26, 2011 3:08 pm

Re: HTML tab indent problem

Postby ludder on Thu Jan 19, 2012 1:19 pm

@amdtek Did you setup the TAB completion for Zen Coding yourself? Afaik Zen Coding is default triggered by CTRL+ALT+Enter (which opens an input line to enter your "zen coding haiku").
Evenmore, the TAB completion in build 2165 is not enabled by default (see: http://www.sublimetext.com/docs/2/auto_complete.html).
On the other hand, ST2 knows the concept of "tab triggers" that are used by code snippets.

Are you sure you were using Zen Coding? ST2 comes with some default snippets like "html", but doesn't know how to handle zen coding input like:
Code: Select all
div#test>ul>li.test-$*8>a{bla$}
ludder
 
Posts: 15
Joined: Tue Nov 29, 2011 9:44 pm

Re: HTML tab indent problem

Postby amdtek on Thu Jan 19, 2012 6:25 pm

@philosopherdog
philosopherdog wrote:Try disabling the packages using the package disable feature and see if that solves the issue. If you have the html5 package installed that's probably the issue.


Of course I removed my html5 package asap I read it could be one of the reasons for conflicts. Otherwise, I don't think the little packages that I have currently must be the root cause(s) for my tab & zencoding problem. Still, here's the list of packages that I am having so far -
    Camaleon
    CSS Less(fish)
    Dogs Color Scheme
    ElasticTabStops
    Indent XML
    PhpBeautifier
    Theme - Soda
    SublimeCodeIntel
    Zenburn
    ZenCoding

@ludder
ludder wrote:@amdtek Did you setup the TAB completion for Zen Coding yourself?

No. But now when I checked the settings under Preferences > File Settings Default, I saw that the auto_complete feature was set to true. I am providing a dump for your convenience below:
// While you can edit this file, it's generally best to put your changes in
// "User/Base File.sublime-settings", which overrides the settings in here.
//
// Settings may also be placed in file type specific options files, for example,
// in Packages/Python/Python.sublime-settings for python files.

{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",

// Note that the font_face and font_size are overriden in the platform
// specific settings file, for example, "Base File (Linux).sublime-settings".
// Because of this, setting them here will have no effect: you must set them
// in your User File Preferences.

"font_face": "Meslo LG M",
"font_size": 10,

// Valid options are "bold", "italic", "no_antialias", "gray_antialias",
// and "subpixel_antialias".

"font_options": [],

// Characters that are considered to separate words
"word_separators": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?",

// Set to false to prevent line numbers being drawn in the gutter
"line_numbers": true,

// Set to false to hide the gutter altogether
"gutter": true,

// Fold buttons are the triangles shown in the gutter to fold regions of text
"fold_buttons": true,

// Hides the fold buttons unless the mouse is over the gutter
"fade_fold_buttons": true,

// Columns in which to display vertical rulers
"rulers": [],

// Set to true to turn spell checking on by default
"spell_check": false,

// The number of spaces a tab is considered equal to
"tab_size": 4,

// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": false,

// If translate_tabs_to_spaces is true, use_tab_stops will make tab and
// backspace insert/delete up to the next tabstop

"use_tab_stops": true,

// Set to false to disable detection of tabs vs. spaces on load
"detect_indentation": true,

// Set to false to disable automatic indentation
"auto_indent": true,

// Set to false to not trim white space added by auto_indent
"trim_automatic_white_space": true,

// Set to false for horizontal scrolling
// NOTE: word_wrap is explicitly turned off in several syntax specific
// settings, you'll need to set it via your user syntax specific settings
// to ensure these are overridden.

"word_wrap": true,

// Set to a value other than 0 to force wrapping at that column rather than the
// window width

"wrap_width": 0,

// Set to false to prevent word wrapped lines from being indented to the same
// level

"indent_subsequent_lines": true,

// Set to true to draw text centered in the window rather than left aligned
"draw_centered": false,

// Set to false to stop auto pairing quotes, brackets etc
"auto_match_enabled": true,

// Word list to use for spell checking
"dictionary": "Packages/Language - English/en_US.dic",

// Set to true to draw a border around the visible rectangle on the minimap.
// The color of the border will be determined by the "minimapBorder" key in
// the color scheme

"draw_minimap_border": false,

// Set to false to disable highlighting any line with a caret
"highlight_line": false,

// Valid values are "smooth", "phase", "blink", "wide" and "solid".
"caret_style": "smooth",

// Set to false to disable underlining the brackets surrounding the caret
"match_brackets": true,

// Set to false if you'd rather only highlight the brackets when the caret is
// next to one

"match_brackets_content": true,

// Set to false to not highlight square brackets. This only takes effect if
// matchBrackets is true

"match_brackets_square": true,

// Set to false to not highlight curly brackets. This only takes effect if
// matchBrackets is true

"match_brackets_braces": true,

// Set to false to not highlight angle brackets. This only takes effect if
// matchBrackets is true

"match_brackets_angle": false,

// Enable visualisation of the matching tag in HTML and XML
"match_tags": true,

// Additional spacing at the top of each line, in pixels
"line_padding_top": 0,

// Additional spacing at the bottom of each line, in pixels
"line_padding_bottom": 0,

// Set to false to disable scrolling past the end of the buffer.
// On OS X, this value is overridden in the platform specific settings, so
// you'll need to place this line in your user settings to override it.

"scroll_past_end": true,

// This controls what happens when pressing up or down when on the first
// or last line.
// On OS X, this value is overridden in the platform specific settings, so
// you'll need to place this line in your user settings to override it.

"move_to_limit_on_up_down": false,

// Set to "none" to turn off drawing white space, "selection" to draw only the
// white space within the selection, and "all" to draw all white space

"draw_white_space": "selection",

// Set to false to turn off the indentation guides.
// The color and width of the indent guides may be customized by editing
// the corresponding .tmTheme file, and specifying the colors "guide",
// "activeGuide" and "stackGuide"

"draw_indent_guides": true,

// Controls how the indent guides are drawn, valid options are
// "draw_normal" and "draw_active". draw_active will draw the indent
// guides containing the caret in a different color.

"indent_guide_options": ["draw_normal"],

// Set to true to removing trailing white space on save
"trim_trailing_white_space_on_save": false,

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

// Set to true to automatically save files when switching to a different file
// or application

"save_on_focus_lost": false,

// The encoding to use when the encoding can't be determined automatically.
// ASCII, UTF-8 and UTF-16 encodings will be automatically detected.

"fallback_encoding": "Western (Windows 1252)",

// Encoding used when saving new files, and files opened with an undefined
// encoding (e.g., plain ascii files). If a file is opened with a specific
// encoding (either detected or given explicitly), this setting will be
// ignored, and the file will be saved with the encoding it was opened
// with.

"default_encoding": "UTF-8",

// Determines what character(s) are used to terminate each line in new files.
// Valid values are 'system' (whatever the OS uses), 'windows' (CRLF) and
// 'unix' (LF only).

"default_line_ending": "system",

// When enabled, pressing tab will insert the best matching completion.
// When disabled, tab will only trigger snippets or insert a tab.
// Shift+tab can be used to insert an explicit tab when tab_completion is
// enabled.

"tab_completion": true,

// Enable auto complete to be triggered automatically when typing.
"auto_complete": true,

// The maximum file size where auto complete will be automatically triggered.
"auto_complete_size_limit": 4194304,

// The delay, in ms, before the auto complete window is shown after typing
"auto_complete_delay": 50,

// Controls what scopes auto complete will be triggered in
"auto_complete_selector": "source - comment",

// Additional situations to trigger auto complete
"auto_complete_triggers": [ {"selector": "text.html", "characters": "<"} ],

// By default, auto complete will commit the current completion on enter.
// This setting can be used to make it complete on tab instead.
// Completing on tab is generally a superior option, as it removes
// ambiguity between committing the completion and inserting a newline.

"auto_complete_commit_on_tab": false,

// Controls if auto complete is shown when snippet fields are active.
// Only relevant if auto_complete_commit_on_tab is true.

"auto_complete_with_fields": false,

// By default, shift+tab will only unindent if the selection spans
// multiple lines. When pressing shift+tab at other times, it'll insert a
// tab character - this allows tabs to be inserted when tab_completion is
// enabled. Set this to true to make shift+tab always unindent, instead of
// inserting tabs.

"shift_tab_unindent": false,

// If true, the selected text will be copied into the find panel when it's
// shown.
// On OS X, this value is overridden in the platform specific settings, so
// you'll need to place this line in your user settings to override it.

"find_selected_text": true
}



ludder wrote:Afaik Zen Coding is default triggered by CTRL+ALT+Enter (which opens an input line to enter your "zen coding haiku").

In the earlier builds (say 2160), if I were to perform any zencoding haiku, then followed by TAB key at the end, then it would be executing it. I've kind of got used with successing the haiku with the TAB key as it's very fast. I know about the CTRL+ALT+Enter too but this one is mostly used to modify in between lines of codes. Say if you wanted to wrap a certain lines, I would use CTRL+ALT+Enter for this. Otherwise simple zencoding like the one provided by you below, I was able to perform those command and by ending it with the TAB key. Now it doesn't work. Sometimes I have to press TAB key more than once, sometimes twice or even thrice.

ludder wrote:Evenmore, the TAB completion in build 2165 is not enabled by default (see: http://www.sublimetext.com/docs/2/auto_complete.html).
On the other hand, ST2 knows the concept of "tab triggers" that are used by code snippets.

It seems to be enabled (i.e. set to 'true') here by default on my ST2. Look out for the same in the dump above for more details. BTW, can you throw some light by providing some examples between how different is a code snippet (and how it is utilized) in ST2 in contrast to zen coding? I mean based from what you are saying, both are somehow very similar. Hence I am placing the request to you to kindly clarify that to me.

ludder wrote:Are you sure you were using Zen Coding? ST2 comes with some default snippets like "html", but doesn't know how to handle zen coding input like:
Code: Select all
div#test>ul>li.test-$*8>a{bla$}

Of course that's Zen coding, I mean the above code you have provided is Zen Coding code, right? I recall I've tried something similar to that (followed by the tab key [I pressed only once) in the earlier build (2160) and it worked like a charm. But now I have been trying to enter similar zen coding codes followed by the TAB key but it just wouldn't work all the times. Or, wait here, did you mean something different by snippet?
amdtek
 
Posts: 3
Joined: Sun Aug 28, 2011 8:55 am

Re: HTML tab indent problem

Postby philosopherdog on Fri Jan 20, 2012 2:19 pm

Sorry I don't have a specific solution, but I would start by disabling all plugins to see if that solves it. Then enable one by one. One thing off hand is you don't need SublimeCodeIntel since that feature is now built in. Also I have had issues with phpbeautifier. Sorry I can't be of more specific assistance.
philosopherdog
 
Posts: 35
Joined: Sat Nov 26, 2011 3:08 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 22 guests