6

I was looking for a code editor that uses a browser rendering engine for its GUI so I can work on code that handles various foreign languages in their native scripts.

I'm trying out Adobe Brackets but when I create a new file I can't find a way to set the programming language to get the syntax highlighting.

This happens for instance when I go to File / New then paste in code from somewhere like JSFiddle.

If I right-click on the name of the file in the left column there is a rename menu item, but it doesn't react so I can't add a .js extension for my JavaScript file.

There is an item in the status bar at the bottom right between the INS/OVR toggle and the lint indicator, but for a new unsaved file with no extension it is greyed out and cannot be changed.

There is a doc page titled Language Support but it seems to only cover deeper technical aspects, such as the editor's programming API.

How can I set the programming language? Is this editor just immature or is there a feature I can't find?

hippietrail
  • 15,848
  • 18
  • 99
  • 158
  • you save the file first. .php for php coloring, .js for js coloring etc. – Daniel Cheung Sep 01 '14 at 06:47
  • 1
    @DanielCheung: Really? That's annoying. Not major for lots of people though I suppose. – hippietrail Sep 01 '14 at 06:49
  • 1
    I can't find it at first too, but I still prefer Brackets over some other editors because of it's simplicity. You should go to their github page and request for this feature though, because people do use multiple languages in a single file, e.g. PHP+HTML+JS – Daniel Cheung Sep 01 '14 at 06:54
  • My guess is they have a "feature" which greys out the language menu in the status bar under some certain circumstances. I just tested it on a file I load via File / Open and in that case I can change between PHP/HTML/JS fine. – hippietrail Sep 01 '14 at 07:00
  • @DanielCheung Multiple languages nested in a single file, like your PHP+HTML+JS example, shouldn't require manually adjusting the language switcher as you move between different parts of the file. The main PHP language mode is smart enough to understand the nesting automatically. (Similar for JS/CSS nested in an HTML file, etc.) – peterflynn Sep 02 '14 at 18:40
  • The code I'm working on that inspired me to try Brackets for the first time actually has a second language embedded in a string. But I wasn't expecting support for that, I just don't like saving "temporary" files. – hippietrail Sep 03 '14 at 03:30

2 Answers2

9

Currently, you cannot switch the language for untitled files. Once a file exists on disk, you can use the dropdown in the status bar to change the language (or just rename the file to a different extension, of course).

Sadly, the only reason it's disabled for untitled files is that the JS code hinting engine (which is quite complex) has bugs when it encounters untitled files. So really, only the JS language option in the dropdown needs to be disabled... but to avoid confusion, the entire switcher is disabled instead.

If you want to see that fixed, please upvote the feature request in the Brackets backlog.

peterflynn
  • 4,667
  • 2
  • 27
  • 40
  • Note that it's also not possible to rename a file that hasn't been saved. But in this case the Rename option isn't even greyed out and nothing is reported. It just fails silently, which seems more buglike than the main problem I was having. – hippietrail Sep 03 '14 at 03:34
  • 1
    @hippietrail Right, I intended renaming to be part of the "once a file exists on disk" clause. You raise a good point though: Brackets is currently not so great at disabling inapplicable menu items in general. I'll look into whether there's a quick way to fix this particular case... – peterflynn Sep 03 '14 at 09:34
  • I like Trello but don't have a feel for it yet. If there's a bug/featurereq for the rename problem then I'll vote on that one too. – hippietrail Sep 03 '14 at 09:39
  • Thanks, I think this option should have to be somewhere in the top menus as well, I spent a lot of time finding it and finally found it here. – qasimzee Mar 18 '15 at 06:43
1

Try manually typing the file type when you save eg: index.html (including the extension) instead of just index

This worked for me!

Andrew
  • 121
  • 4