0

I´ve installed Babel JSX support in my Sublime Text 3.

It works fine, but sometimes I loose formatting os certaing pieces of the code.

To recover the correct coloring and highlightining, I just go View->Syntax->Babel->Javascript (Babel).

At the end of the day I keep doing this procedure tons of times, as I´m always loosing formatting.

I need to solve 2 problems:

a) I want to put operation in a F key. I´ve tried with no success the following key binding:

{ "keys": ["f11"], "command": "set_file_type", "args": { "syntax": "Packages/JavaScript (Babel).tmlanguage"}}

It gives me an error saying it cannot find the package and loosing all formatting.

How to put the View->Syntax->Babel->Javascript (Babel) to a function key ?

b) Does anyone knows why Sublime Text 3 loose formatting with JSX code ? This happens when I open a saved file or when I create an arrow function. Just after selecting View->Syntax->Babel->Javascript (Babel) it turns to highlight correctly.

Any ideas if this is a package bug and how to solve it ?

Thanks for helping.

Mendes
  • 17,489
  • 35
  • 150
  • 263
  • Possible duplicate of [Set default syntax to different filetype in Sublime Text 2](https://stackoverflow.com/questions/7574502/set-default-syntax-to-different-filetype-in-sublime-text-2) – idleberg Aug 30 '17 at 21:36
  • @idleberg. Its not a duplicate. Questions and problems are different – Mendes Aug 30 '17 at 21:57
  • It fixes the cause of your problem rather than being a workaround to restore the syntax highlighter – idleberg Aug 31 '17 at 04:13
  • No. Adding a shortcut is not a workaround. And setting a default language does not fix the problem... – Mendes Aug 31 '17 at 10:36
  • I don't know how to assign a keyboard shortcut to specify a syntax. However, you would not need to use a shortcut if the problem didn't occur. And that's the bit that makes your question a duplicate, because assigning a default syntax to a certain file-type would be persistent. Maybe you should split this into two questions – or rephrase it if i misunderstand what you're after. – idleberg Aug 31 '17 at 10:41

0 Answers0