How to auto indent in WebStorm - intellij-idea

I need to indent multiple files in WebStorm. Its option "Auto-indent" in the Code menu only indents current line.
How do I use it on multiple files like I can use "Reformat Code"?

Select the folder you want to reformat the code for in the Project tool window. Then select Code | Reformat Code
This page explains it. https://www.jetbrains.com/help/idea/2016.1/reformatting-source-code.html

Related

Is there a shortcut in IntelliJ that allows you to create a boilerplate HTML file like in VSCode?

In VSCode you can basically type '!' then hit enter and you get a boilerplate HTML document. I love that feature and I wonder if IntelliJ has the same. If it doesn't how could I make it myself? I've tried macros, but it's not instantaneous it types every character one after the other. I've searched for their html shortcuts in keymap and didn't find anything of that sort. Their doc is not helpful either. Do you guys have any idea or hack on how to do that?
You can define a custom Html file template(https://www.jetbrains.com/help/idea/settings-file-and-code-templates.html) from File | Settings/Preferences | Editor | File and Code Templates.

Intellij is using different indention within the same .vue file

In the <template> area Intellij is using 2 spaces for indention and for the <script> part it's using 4 spaces. I get errors running npm run dev because of the different indention.
I have set Intellij to use 4 spaces for all filetypes that I could find (not including JS or .vue). The project itself uses 2 spaces (I would like to change that).
However, now like I said it's using two different indention styles within the same file and that causes a whole lot of problems.
Code -> Reformat code changes the code to this style with 2 different indentions.
Any idea what's going on? Thanks!
First, make sure you don't have Detect and use existing file indents for editing enabled in Settings/Preferences | Editor | Code Style. If you do, when you auto-indent, it might apply the wrong settings.
Then, try reformatting the code using Control+Alt+L or Code -> Reformat Code.

How to get HTML-formatted code from clipboard? [duplicate]

Is there a simple way to copy syntax-coloured code block as rtf in intellij IDEA?
UPDATE: there is now a new plug-in for this: 'Copy' on steroids that is maintained by JetBrains.
There is no way to copy colored code block from IDEA directly.
A workaround is to use File | Export to HTML, then open HTML in a browser, then copy from the browser window and paste into Wordpad or MS Word.
Another and more faster way is to install the Copy as HTML plug-in in Settings | Plugins:
Copies a snippet of code as html
Adds menu items "Copy as HTML" to main menu and editor popup. Will copy the current selection or the complete editor buffer. Currently only works if focus is in editor (for example won't work in project tree).
Preserves more formatting than the built-in HTML export.
HTML is only a snippet (without html and body tags) meant to be inserted into a complete HTML document.
Currently HTML format is fixed and uses CSS a lot.
Options: unindent, add border, padding, line numbers, tabs to spaces conversion, include editor's warning and error highlighting (see IDE Settings -> Copy as HTML).
Reuses the editor "Show Line Numbers" setting (see Idea's "View" menu).
IntelliJ IDEA 15
By default, you can copy rich text from IntelliJ to Microsoft Word (for example).
This feature can be found in File > Settings... > Editor > General > Rich-text copy > Copy as rich text by default
You can also change the color scheme only for the copy-paste operation (your current scheme won't be affected).
Go to https://gist.github.com/
Copy code from IntelliJ to the new private gist;
Save it, copy colorful code from the browser to wherever you want;
Delete the gist.
Use external tool notepad++
1) copy code snippet to notepad++
2) apply syntax highlighting
3) copy with nppexport plugin to clipboard as rtf
If you're on a mac and like TextMate, here's a great way to copy styled code from TextMate: https://github.com/bblimke/copy-with-style-tmbundle
It's not as convenient as doing it directly from IntelliJ, but it's a bit more convenient than using gist or pastebin. Also, unlike the Copy as HTML Plugin for IntelliJ, this solution actually works at the time of this writing.

Notepad++ stopped color-coding my source code... How to fix?

For no apparent reason, it just stopped. No more color-coding. Is there a mystery setting I accidentally turned off?
I had the same problem and discovered it was because I had enabled global foreground color under Global Styles.
Try out the following:
Select a language manually from the "Languages" menu.
In Settings/Preferences, check the File Associatons.
In worst case, reinstall.
In the Language menu select your corresponding language. For example H and then html
The solution for me was to go into the Style Configurator, select the 'Global Styles' from the Language selection box and uncheck the 'Enable global foreground colour' option. I am not sure why that was checked, but all of the code coloring worked after unchecking it. Thanks Richard!
Have a look in Settings -> Style Configurator. Maybe your styles got messed up somehow. You could try changing the selected style to see if it makes a difference.
I think the saved styles are stored in the "themes" directory under your Notepad++ installation directory, so you could also check that the files have not become corrupted in some way.
I had the same problem (I Googled "notepad++ file coloring quit" to find this discussion.) In my case the coloring quit mid file in a single file. I finally realized that adjacent string literals with one of them a macro was fooling Notepad++.
My code that broke it read:
Write_Supplemental_Configuration(privateData->new_config, FTP_ROOT_DIR"/lists.csv");
and the fix was to add a space after the macro:
Write_Supplemental_Configuration(privateData->new_config, FTP_ROOT_DIR "/lists.csv");
I tried replacing the macro FTP_ROOT_DIR with "foo" and the problem went away.
So in my case it was a macro that fooled the Notepad++ coloring.
watch out for the single quote that you copy from the web. if you get one of those "upper commas" instead of the tic mark it will confuse the code and kill the coloring (in SQL). just delete and replace.
Make sure that when you save the file it's saved as an .html instead of a .txt. This make a difference because the .html allows you to see the different colour codes whereas .txt doesn't.
Check, if you have saved the documents as .HTML and not as .txt
in the menu, choose Settings>Style configurator...
and in the list in the left pan select html, check if the colors for different tags are being shown in the color blocks. if yes, chosse a font and then save and exit.
Check only after you save the document in .html, whether it is working or not.
The language setting solved the issue for (all) 3 Javascript files (.js) which suffered from it, which previously were all recognized correctly as Javascript. For some reason it forgot they were Javascript files apparently!?
First type any thing and Save the file in any format you are working with (i-e; .cpp if c++, .js if JavaScript....etc)
And make sure global foreground color is disabled.
And it should work fine.
File > Save As > Format Type = Structured Query Language > Name the file with '*.sql'. THIS SHOULD BRING ALL THE COLOR CODES.....to differentiate your code and make it look pretty. J
If you want to display text in SQL format, then in menu select Language => S => SQL
Got to Setting -> Style Configuration and remove the global style checkbox
I just had the same thing happen to me. The only way I could fix it was to rename the file (I just added one character). Then open it with notepad++. The code was colored again. Then renamed the file back to the original name and it is still colored.
I have since found that if I close Notepad++ without closing the file first this happens. Try closing the file first then close Notepad++ then reopen the file.
This bug seems to be fixed as of version 7.8.6
If the coloring only stopped working for one file, you should check the extension name of your file. You might have accidentally saved the file as .txt
A couple years late here, but I'm pretty sure you're opening ".txt" files that contain your source code. Because the file doesn't have the language's extension, Notepad++ can't determine how to color-code it. You'll have to select the language under the "Language" tab.

Copy syntax-coloured code block as rtf in intelliji IDEA?

Is there a simple way to copy syntax-coloured code block as rtf in intellij IDEA?
UPDATE: there is now a new plug-in for this: 'Copy' on steroids that is maintained by JetBrains.
There is no way to copy colored code block from IDEA directly.
A workaround is to use File | Export to HTML, then open HTML in a browser, then copy from the browser window and paste into Wordpad or MS Word.
Another and more faster way is to install the Copy as HTML plug-in in Settings | Plugins:
Copies a snippet of code as html
Adds menu items "Copy as HTML" to main menu and editor popup. Will copy the current selection or the complete editor buffer. Currently only works if focus is in editor (for example won't work in project tree).
Preserves more formatting than the built-in HTML export.
HTML is only a snippet (without html and body tags) meant to be inserted into a complete HTML document.
Currently HTML format is fixed and uses CSS a lot.
Options: unindent, add border, padding, line numbers, tabs to spaces conversion, include editor's warning and error highlighting (see IDE Settings -> Copy as HTML).
Reuses the editor "Show Line Numbers" setting (see Idea's "View" menu).
IntelliJ IDEA 15
By default, you can copy rich text from IntelliJ to Microsoft Word (for example).
This feature can be found in File > Settings... > Editor > General > Rich-text copy > Copy as rich text by default
You can also change the color scheme only for the copy-paste operation (your current scheme won't be affected).
Go to https://gist.github.com/
Copy code from IntelliJ to the new private gist;
Save it, copy colorful code from the browser to wherever you want;
Delete the gist.
Use external tool notepad++
1) copy code snippet to notepad++
2) apply syntax highlighting
3) copy with nppexport plugin to clipboard as rtf
If you're on a mac and like TextMate, here's a great way to copy styled code from TextMate: https://github.com/bblimke/copy-with-style-tmbundle
It's not as convenient as doing it directly from IntelliJ, but it's a bit more convenient than using gist or pastebin. Also, unlike the Copy as HTML Plugin for IntelliJ, this solution actually works at the time of this writing.