I'm following the tutorial in https://tour.golang.org/
There are some options on the top right corner of the interactive window.
Syntax On is obvious which enables/disables syntax highlighting of the code inside the window.
The other one, Imports On, which I tried to switch on/off and run the code but it doesn't seem to make a difference.
What does this option do exactly?
Imports On/Off enables or disables goimports.
To test out an example, remove (or add, or modify) any of the import lines in one of the examples, then click Format. This will automatically add/remove imports based on the packages used in the code.
goimports is very convenient to have as a save hook in your editor to automatically set imports for you (and cleanup, which is something that can easily be forgotten).
automatically imports the package you have mentioned when you hit format
Related
I recently changed my VSCode settings to stop suggestions and someone disabled a setting for SCSS files, where I could type
.example {}
hit return and this would automatically change to
.example {
//cursor positioned here
}
I cannot figure out how to restore this setting, losing my mind trying to find extensions or suggestions. Please help!
Specifically about your question
As mentioned in the comments by #Brad, it may be related to settings. However, the disabled setting may be in your settings.json file, which can have configuration not seen in the settings editor.
The easiest way to get to it is by using the command palette. The shortcut is cmd+p on a mac or ctrl+p in windows, and you can search for settings:
in the settings.json file, you can have language-specific settings. Look for something tied to scss, which would have brackets around it. My guess is that you may have one or more of these commands set to false:
You may also need to check your workspace settings as well, because they can have settings active for a single folder. Using the command-palette again, you can find it by typing "workspace"
A more general suggestion
I would recommend against turning off such a broad feature as code suggestions. They can be very helpful, and although this is a personal choice, learning to use them to your advantage can be highly productive in VS Code. One of the perhaps underused features of vscode is the ability to have custom snippets for any given language.
In order to achieve the behavior described in your answer, for example, I would configure a snippet like this:
"StackOverflow Answer": {
"prefix": "dotexample",
"body": [
".example {",
"\t$0",
"}"
],
"description": "Creates a .example selector"
}
Then, in any scss file I would simply type the value found in the prefix property above, and I would see my snippet:
by using the tab key, I would then have those lines of code defined in the snippet, with my cursor placed in the position I want to type in:
This code took me 10 seconds to configure, and three keyboard keys to insert. If you type it often, it can be a huge productivity booster!
Anyway, like I said, personal preferences vary. But the more you learn about your IDE, the better your usage choices will be.
Good luck!
Use IntelliJ IDEA for macOS. Problem
Whenever I do ⌥+⌘+L (shortcut to reformat code in macOS), code clean up does not apply.
I noticed that because I turned on the Final Modifier already (Make generated local variables final and Make generated parameters final in Settings: Editor -> Code Style -> Java -> Code Generation). But after shortcut, no finals are added.
However, if I do ⌥+⇧+⌘+L to open the reformat dialog and click run, it does add final to variables and parameters). It also work when I right click the file and choose reformat code.
I don't know why, isn't ⌥+⌘+L a shortcut that should do exactly the same thing?
This bring out my other question, is ⌥+⇧+⌘ really applying all my customize settings in Code Style and Inspections (assume I selected the right scheme (under Code Style) and profile (under inspections)?
My last question is, for example, let's say I have a custom scheme in IDE level for Code Style. Every time when I clone a project from let's say GitHub, how do I make the project automatically using my custom scheme instead of using the Project scheme and the Default scheme? Every time I have to go to Code Style and manually switch from "Stored in Project" to "Stored in IDE", so that I can select my custom scheme and click apply. Is there an easy way? Same for Inspections profile, I have to manually switch.
I have tried to solve these for so long, any help will be appreciated! Below are some links I found, but didn't solve my questions
Reformat code
Reformat file dialog
Code Style
I wrote a dat file for when I'm writing assembly to give me some syntax highlighting, the problem I am running into is that one way to do a comment in MASM is to use a semicolon and you typically tab a fair bit away from the actual code before you write the comment (at least I do). Well whenever I do this, it messes up all of the formatting in the .asm file because it tries to format the document whenever it sees a semicolon, I am wondering is there a way to turn off auto tabbing and other stuff via a dat file? I just know how to load a dat file that tells the editor some words to highlight, that's it.
Thanks in advance for any input on this :)
You can export the specific settings for a certain project and then import it later. This will save .vssettings XML format file.
Just define you tab setting before in Options dialog from the Tools menu, selecting the Text Editor -> Your prefered language-> Formatting -> General page, and unchecking relevant check- box ( in your case tabbing).
Then in Tools > Import and Export Settings , export the settings.
I hope it sort your issue.
I have somehow added two SCSS syntax highlight options. One of keeps resetting to be the default (but it doesn't correctly highlight SCSS, it looks more like how the plain CSS highlighter does).
Every time I open a file I have to manually set it to be the correct one through the command pallet.
Here is a screen shot showing them both:
Check your installed packages. I guess it is from a third party package.
You also could deactivate them all and reactivate them one by one to find the package bringing the wrong highlighter.
I'm trying to get rid of a ton of unnecessary fully qualified types and instead throw in a using at the top of these classes.
I am not sure if there is some kind of batch that would go out and do this for me. Right now I have to use ReSharper and erase the redundant portion of a type and then of course ReSharper asks to throw in the missing using and that's how I am going through each class manually cleaning these up.
There's got to be a more automated way where I can run some process to go through all the project in this solution and do this for me ..just like I'm having to do manually with each line of code with ReSharper?
You should use Code Cleanup. To run on a single file, go to ReSharper | Tools | Cleanup code, select Full cleanup or create your own profile with Optimize 'using' directives and Shorten qualified references turned to Yes. Maybe Remove code redundancies should be turned to Yes also.
You can run Code cleanup on several files. To do it, select necessary files in Solution explorer, press right mouse button and run Code cleanup from popup menu.