this question applies to both ST and ST2. It has to do with the line-breaking algorithm when working with word wrapping on, as is the case for LaTeX files.

Suppose the cursor is at the last line position in the window, and you want to type, e.g., "sublime". You type the s, which appears on the current line; then you type the u, and both the s and the u are moved to the following line. All is well---it's what you want to happen.

However, suppose you want to type a LaTeX command instead, e.g. \emph, starting from the same position as before. You type the \, then you type the e, and nothing special happens: the \ remains on the first line, and the appears in the following line. The same is true if you use e.g. a brace ("{") or the inline math symbol "$".

This is undesirable, as it makes the document harder to read. TextMate does not have this issue: \'s, $'s, {'s etc. all move to the next line if necessary. Is there a setting to control this anywhere?

Thanks!M

PS: I'm slowly porting the LaTeX plugin to ST2. I'll post an announcement when I have something useable.

I'm probably missing something, but I do get the behavior you expect with the default settings: sequences like "\emph" are pushed to the next line as a unit if typed at the end of a line with word wrap on. Tried with a plain txt file, though, no LaTeX.

Completely unfounded idea: maybe Sublime uses the tmLanguage to make assumptions about where to split the text? What you describe does happen in *.py files too. I would be confused what the purpose of the option mentioned above would be then, and why Sublime would need to disambiguate in some cases.

I thought about that, too. However, I am not smart enough to figure out where this happens

Also, this issue does not arise with TextMate, and I'm guessing that the LaTeX.tmLanguage file is the same as TextMate's (there are references to TeXshop. a popular Mac TeX editor). Of course, ST2 and TM could be interpreting the same file in different ways...

guillermooo is correct: the tmLanguage is used to tokenise the text, and these tokens are used as word wrapping units. The reasons for this are largely historical, but I won't be in a position to change this until the Shiny New Text Buffer work gets underway, which won't be happening until well after the stable version of 2 is released.

word_separators are used for other things, such as navigating by words.

OK, thanks for the clarification. Do you think it would be possible to tweak the tmLanguage file so as to not break things, but still ensure that backslashes stay with their associated command (e.g \emph etc.)? WHere should I look? Thanks!

As an example, the '\' and the 'emph' are assigned different scopes by LaTeX.tmLanguage, which causes Sublime Text to treat them as two separate tokens. If you changed the regex to not assign the '\' its own scope, then it would be placed in the same token.