In Visual Studio Code (under Windows), my present Json files are displayed as the following :
I would them to be formatted as displayed below :
Open the json file and SHIFT + OPTION + F for mac
In 2022 it's Ctrl+Shift+I as stated on the Visual Studio Code website.
Use ALT-SHIFT-F to auto format a json file in windows
Press Ctrl-Shift-p to format the documents. I don't know if this shortcut works on Windows, but it does on Linux.
Install a code formatting extension then save the file.
Install Prettier using the extensions, and then right click, select format document with and pick Prettier.
Related
All programmers in the company I work at use PhpStorm and PhpStorm formatter. I prefer using VSCode, which creates a problem, my code is formatted and indented differently.
I like to use the formatter that exists in PhpStorm, whether by exporting and importing it somehow or by changing the settings of VSCode formatter, or by using an extension.
I am using phpfmt extension to format the visual studio code. You may set your own shortcut key for this also. For this go to preference keyboard shortcut and type phpfmt and change your shortcut key.
there is the extension vscode code which might help you
PHPStorm Formatter
click here to get the vscode extension
it may seem as a dumb question, but I started using VS for HTML and CSS coding I can't seem to find how to export my project. I found help on Microsoft Developer Centre or what and I just can't find it. Can you give me a better explaination?
Thanks.
I suggest you use another code editor for html css,like notepad ++ , sublime text and so on, visualstudio focused on .net apps .
Visual Studio doesn't export your code , for .net apps it will debug and build your app with needed files also you can use save all as option from file menu to select where to save your files
For exporting your project in vs Studio you should:
Right click on your project then Select Export Program.
Under Export toolchain, select Visual Studio Code
Click Export, and unpack at a convenient location.
I often need to use a text editor while writing code to paste random notes but especially JSON responses, where I format them using a plugin (for Sublime).
I recently heard about the 'scratch file' feature in IntelliJ / Android Studio which does exactly what I need it to - except I can't make it format JSON I paste in nicely.
How can I make Android Studio format JSON in a scratch buffer file?
I highlight the code and run Command Option L (a short-cut for the Code->Reformat Code menu).
On Windows use Ctrl Alt L.
Note that this only works if the code is well-formed JSON (clear any red squiggles).
You are asking about two seperate things: scratch files and scratch buffers.
When you create a scratch file in IntelliJ you can choose the type of the file (e.g. JSON) that you want to create. Based on file's type, IntelliJ provides code formatting (use Code->Reformat code).
However, scratch buffers are just simple .txt files and the only formatting that can be used is the one associated to .txt format. So, if you put JSON into scratch buffer it won't get formatted with JSON type formatter.
I would encourage you to use scratch files instead of scratch buffers if you want JSON formatting.
More information can be found at IntelliJ's official page https://www.jetbrains.com/help/idea/2016.2/scratches.html.
choose from the menu : code -> reformat code
hotkey On Windows -:
CTRL + Alt + L
Important note- if you have sensitive information in your JSON- NEVER use online tools to parse or beautify it. because this will compromise your organization's and customer's information
If you run the latest version I'd create a new Scratch File of type JSON.
It's really easy, e.g. hit double shift, then search for new scratch file, select JSON as the language, paste your snippet and then use the shortcut that you usually use for formatting any file in intelliJ.
There is a plugin Save Actions that does auto-formatting (also of JSON) every time when I save the file:
select Android Studio > Preferences > Plugins
check Martketplace tab and search for Save Actions (it has a red square-ish icon) and press Install next to it.
At this point you will need to restart your android studio, and then you can enable "Reformat on save" by:
select Android Studio > Preferences > Other Settings > Save actions, in there, select:
✅ General > activate save actions on save
✅ Formatting actions > Reformat File
Is there a way to re-indent a block of code? I'm looking for something similar to Ctrl+Shift+F in Eclipse (Auto-Format/Indent).
To be clear,
I already know how to format XML outside of Notepad++ (Eclipse works fine, as mentioned) so I don't need a bunch of links to other XML-formatting tools.
I'm specifically working with XML and HTML.
Ideally, there's a keybinding as convenient as the one in Eclipse, so I don't have to break my workflow.
I already know about NppAutoIndent - it won't work, as I'm working with XML, HTML and CSS.
Since I upgraded to 6.3.2, I use XML Tools.
install XML Tools via the Plugin Admin (Plugins → Plugins Admin... Then search for "XML Tools", check its box and click the "Install" button).
use the shortcut Ctrl+Alt+Shift+B (or
menu → Plugins → XML Tools → Pretty Print)
In older versions:
menu → TextFX → HTML Tidy → Tidy: Reindent XML.
Install Tidy2 plugin. I have Notepad++ v6.2.2, and Tidy2 works fine so far.
For those who don't know, npp has a lot of support from plugins and other projects. You can download those plugins from SourceForge.
You need XML Tools to format your text in n++
After you have downloaded XML Tools ..
Exit Notepad++
Go To C:\Program File\Notepad++ .... Your N++ installed folder.
Place below files from xml tools which you downloaded in the npp root folder by copy replace
Go To ..\Plugins subfolder and place below downloaded file
Restart and enjoy!!!
Ctrl + Alt + Shft + B to format.
It's been the third time that I install Windows and npp and after some time I realize the tidy function no longer work. So I google for a solution, come to this thread, then with the help of few more so threads I finally fix it. I'll put a summary of all my actions once and for all.
Install TextFX plugin: Plugins -> Plugin Manager -> Show Plugin Manager. Select TextFX Characters and install. After a restart of npp, the menu 'TextFX' should be visible. (credits: #remipod).
Install libtidy.dll by pasting the Config folder from an old npp package: Follow instructions in this answer.
After having a Config folder in your latest npp installation destination (typically C:\Program Files (x86)\Notepad++\plugins), npp needs write access to that folder. Right click Config folder -> Properties -> Security tab -> select Users, click Edit -> check Full control to allow read/write access. Note that you need administrator privileges to do that.
Restart npp and verify TextFX -> TextFX HTML Tidy -> Tidy: Reindent XML works.
Not exactly a solution but a workaround.
Notepad ++ doesn't provide any such feature by default. But you can use some online tools to autoformat text like https://www.freeformatter.com/xml-formatter.html.
I had to update the proxy settings under Plugins -> Plugin Manager -> Show Plugin Manager -> Settings to see any PlugIns in the "Available" list.
After that, installing "XML Tools" was easy and did the requested job as described above.
Just install the latest notepad++ and install indent By fold. On the menu bar select Plugins -> Plugins Admin and selct indent By fold and the install. Works finest
To directly answer the OP, take a look at this guy's site: Thomas Hunter Notepad++ Tidy for XML. Simple steps to follow and you get very nice formatting of your XML right inside NPP. So far the only anomaly I've found is with nested self closing elements EG:
<OuterTag>Text for outer element<SelfClosingTag/></OuterTag>
Will be tidied up to:
<OuterTag>Text for outer element
<SelfClosingTag/></OuterTag>
There may be a way to fix this, but for the time being, it's managed to reduce the number of lines in my document by 300k and this particular anomaly can be worked around.
I'm using Notepad 7.6 with "Plugin Admin" and I could not find XML Tools.
I had to install it manually like #some-java-guy did in his answer except that my plugins folder was located here: C:\Users\<my username>\AppData\Local\Notepad++\plugins
In that directory I created a new directory (named XmlTools) and copied XMLTools.dll there. (And I copied all dependencies to the Notepad++ directory in Program files.)
I would like to format my HTML with a command, as I do in Visual Studio, using Ctrl+K+D. Is this possible in Atom? If not, are there other options?
Atom does not have a built-in command for formatting html. However, you can install the atom-beautify package to get this behavior.
Press CTRL + SHFT + P to bring up the command palette (CMD + SHFT + P on a Mac).
Type Install Packages to bring up the package manager.
Type beautify into the search box.
Choose atom-beautify or one of the other packages and click Install.
Now you can use the default keybinding for atom-beautify CTRL + ALT + B to beautify your HTML (CTRL + OPTION + B on a Mac).
There are a few packages for prettifying HTML. You can find them by searching the Atom package archive:
Navigate to the Atom site
Click the Packages link
Enter "prettify" in the search box
Or just go to this link: https://atom.io/packages/search?q=prettify
Once you've selected a package that does what you want you can install it by using the command: apm install [package name] from the command line or install it using the interface in Preferences.
When the package is installed, follow its instructions for how to activate its capabilities.
https://github.com/Glavin001/atom-beautify
Includes many different languages, html too..
You can add atom beauty package for formatting text in atom..
file --> setting --> Install
then you type atom-beautify in search area.
then click Package button..
select atom beuty and install it.
next you can format your text using (Alt + ctrl + b)
or
right click and select beautify editor contents
Go to "Packages" in atom editor.
Then in "Packages" view choose "Settings View".
Choose "Install Packages/Themes".
Search for "Atom Beautify" and install it.
Not Just HTML, Using atom-beautify - Package for Atom, you can format code for HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, SQL, and more) in Atom within a matter of seconds.
To Install the atom-beautify package :
Open Atom Editor.
Press Ctrl+Shift+P (Cmd+Shift+P on mac), this will open the atom Command Palette.
Search and click on Install Packages & Themes. A Install Package window comes up.
Search for Beautify package, you will see a lot of beautify packages. Install any. I will recommend for atom-beautify.
Now Restart atom and TADA! now you are ready for quick formatting.
To Format text Using atom-beautify :
Go to the file you want to format.
Hit Ctrl+Alt+B (Ctrl+Option+B on mac).
Your file is formatted in seconds.