How to set the programming language for syntax highlighting etc in Adobe Brackets editor?
Asked Answered
M

2

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?

Menfolk answered 1/9, 2014 at 6:40 Comment(6)
you save the file first. .php for php coloring, .js for js coloring etc.Pycno
@DanielCheung: Really? That's annoying. Not major for lots of people though I suppose.Menfolk
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+JSPycno
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.Menfolk
@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.)Ashliashlie
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.Menfolk
A
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.

Ashliashlie answered 2/9, 2014 at 18:38 Comment(4)
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.Menfolk
@Menfolk 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...Ashliashlie
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.Menfolk
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.Mendelsohn
D
1

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

This worked for me!

Dunfermline answered 6/11, 2015 at 20:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.