I have only just started using Adobe Brackets for HTML development. As a programming newcomer, I am still not savvy enough to look in all the right places to change defaults. When I type a beginning tag in Brackets (HTML) like < p >, the editor automatically adds the ending tag < /p >, assuming that I will enter text between the two tags. So I get < p > < /p >. Often I want to put the tags around existing text and do not want the auto completion of the end tag upon entering the beginning tag. How do I change the default in Adobe Brackets so that I do not get the auto-completion of the end tag?
2 Answers
You can do this by setting the dontCloseTags
option in the Brackets preferences file.
- Go to the
Debug
menu and selectOpen Preferences File
. You will see a side-by-side view ofdefaultPreferences.json
on the left andbrackets.json
on the right. These are Brackets' default settings and your settings file, respectively.defaultPreferences.json
lists all the possible options that can be set and their default values, but the file itself can't be modified. - Look at the comments in
defaultPreferences.json
forcloseTags
. What we care about isdontCloseTags
. Set
dontCloseTags
inside ofcloseTags
. For example, mydefaultPreferences.json
file looks like this:{ "fonts.fontSize": "12px", "fonts.fontFamily": "'SourceCodePro-Medium', MS ゴシック, 'MS Gothic', monospace", "themes.theme": "dark-theme", "useTabChar": true, "tabSize": 5 }
And so I would set it up like this, adding a comma after the last entry before starting a new one below:
{ "fonts.fontSize": "12px", "fonts.fontFamily": "'SourceCodePro-Medium', MS ゴシック, 'MS Gothic', monospace", "themes.theme": "dark-theme", "useTabChar": true, "tabSize": 5, "closeTags": { "dontCloseTags": ["p", "img"], "whenOpening": true } }
I set
whenOpening
totrue
because I found that sometimes Brackets won't autocomplete any tags without me asserting that value, even though it's the default.Press Ctrl + S to save your preferences and then close the two files.
- Click on the icon next to the settings icon next to the
Left
heading in the sidebar, then selectNo Split
. This will remove the two columns.
I hope this helps, and have fun looking at the other settings in defaultPreferences.json
, since Brackets won't add a front-end for those settings for a while (it's in the works). Just make sure to match the syntax exactly as it is in defaultPreferences.json
(except for the comments). JSON also wants commas between stuff inside {} and [], but do not add a trailing comma after the last item in each grouping. If the option you want is inside another option (for example, dontCloseTags
is inside of closeTags{}
), you need to include the main option and its grouping symbol thing.
-
1Thanks...I found the entries...and now the really dumb question. My defaultPreferences.json file is not editable. A few settings show up in brackets.json but not all,in particular not the closetags options. How do I edit this defaultPreferences.json? Thanks again. Jun 8, 2016 at 15:52
-
Edit the file on the right, the default file shouldn't be touched ;) You'll have to add the entries you want manually. I'll update my answer when I get to my laptop. Jun 9, 2016 at 15:00
-
Thanks...I would appreciate detailed instructions on how to do it. I have added the entry manually to the right file at the end and in the middle, many times and after saving the file, closing Brackets and opening it again, I get an error message saying this is not a valid json file. When I remove the entries and repeat, I do not get the error message. A little bit frustrating. Jun 10, 2016 at 4:29
-
Oops, I managed to completely forget about this until now. Let me know if you have any questions still. Jun 10, 2016 at 5:25
-
Thanks! That worked...I thought I had done that before, but obviously I was typing in something wrong. Jun 11, 2016 at 16:22
Just use a boolean "false" for the value of the field name(s) if you want to shut that object to not function at all
"closeTags": {
"whenOpening": false,
"whenClosing": false
}
This sets the value of the closeTag field with Boolean defined values of two more objects which results with all auto-completing, closing tags to stop working.
After saving your changes, be sure the new file is loaded by restarting the application. All save does is saves your edits, any changes will not be seen until you restart the application.