VS Code Intellisense don't suggest snippet at first - intellisense

I want to use code snippets in VSCode. But when I type, for example, for in javascript file, the Intellisense doesn't suggest snippet "for-loop" - I need to manually scroll the dropdown and select it. Is there any way to make VSCode to suggest snippets at first? Thank you!
UPD: I have found the person with same problem, but he has no answers - link

You need to use editor.snippetSuggestions config option with "top" value. Please, see Customizing IntelliSense article for more tips and tricks.

There is one more way to deal with this issue by setting
"editor.tabCompletion": true,
that way whenever there is a snnipet available it will use it automatically without even opening the list by using tab twice.
File > Preferences > Settings (Code > Preferences > Settings on Mac)
open "Editor" menu on the left
edit "editor.tabCompletion": true
more info: https://code.visualstudio.com/docs/editor/intellisense#_customizing-intellisense

Now that VS Code mostly abstracted away the settings.json file, you can do the instructions shown by Kavu, with this bonus tip:
go to Preferences > Settings
find the Search settings text input, at the top
type in "snippet"
The setting should be at the top of the result set:

Setting editor.snippetSuggestions to top only works for certain snippets: for but not foreach. With top, the snippet does appear higher in the completion list, but for some reason the keyword version is what is highlighted, with the snippet option scrolled out of view (and the scrollbar quickly fades, giving the impression there's nothing hidden)
The editor.tabCompletion to true approach works for both for and foreach.

Related

How to find the name for indentation of object-attributes in .tsx-file in PhpStorm

I'm editting a .tsx-file and are reaching upon this bonkers file-formatting:
... If I enlarge the window a bit, then it makes more sense:
But I would still like to change it, so value and onClick aren't aligned all that way to the right. Ideally, it would try to align them with the opening bracket (as they do), unless the opening bracket is more than 35 characters, from the line start. Or something like that.
Now, I assume that it's the TypeScript-formatting that dictates the Code Style for a .tsx-file. But when I open the settings: Editor >> Code Style >> TypeScript then there are BAZILLIONS of settings.
Which leads me to three questions:
Does anyone know what I need to change, so object-attributes doesn't follow the opening-brackets width?
Could I find the name of what I'm looking for, in some smart way? I tried hovering over the massive space, hoping that the little yellow light-bulb could shine some light on, what I was after.
Are there any presets, to be found somewhere? So I don't need to engineer a new Code Style, if I dislike the default.
Make sure that the following option is disabled:
Settings (Preferences on macOS)
Editor | Code Style | TypeScript | Wrapping and Braces
Function call arguments: Align when multiline
NOTE: It is possible that the default value has been changed somewhere since the previous version as I have seen a few questions for the same option but different language (PHP and JavaScript).
HINT 1: Did you know that you can paste your own code in the preview area and start changing options to see how they will affect it? It helps locating the right option a lot.
HINT 2: There is a special popup that shows formatting rules applied to the code. It does not show all possible options but can give you a hint what to look for. To invoke it:
Use Help | Find Action... (or Action tab on Search Everywhere -- they use to be different popups but are using the same popup nowadays)
Type adjust to filer actions
Select and invoke "Adjust code style settings" action
It will give you a popup with applicable rules (it's a limited set: may not list all).
An example for PHP code:

How to list all suggested quick actions

Is there a way to list all the suggested Quick Actions for an open project in VS2017 (v15.3.3)?
I do not see any listed in the Error List window (even with "Build + IntelliSense" selected), though I do see other types of IntelliSense warnings such as CS warnings (e.g. CS1591).
(Quick Actions being the items that are marked in the gutter with a light bulb and accessed with either Alt +Enter or Ctrl+.)
Thanks to a response from the #VisualStudio twitter account, I've come across this MS Docs page that answers this question: https://learn.microsoft.com/en-us/visualstudio/ide/code-styles-and-quick-actions?utm_source=t.co&utm_medium=referral
It describes how to set code style preferences by opening the Tools > Options window and selecting Text Editor > C# / Basic > Code Style > General.
Here there are a list of the code style preferences. To see where they are suggested in one's own code the severity of each can be changed, say from "None" to "Suggestion" or "Warning". Then, during a build, the locations for the related style will be listed in the Build Output or Errors windows
This isn't exactly the same as what you're looking for, but could help you make changes much more quickly to the entire document, project, or solution:
When you try to apply a quick action (using Ctrl + .), you'll get a preview of the changes it will make. At the bottom of that preview is a button that says
"Apply to all occurrences in ..."
This will save you from having to go to every single occurrence in a certain scope and fixing it, which is what I've done for a couple of hours now :(

PHPStorm Live templates not expanding

I've just started to play araound with PHPStorm and I can't get the live templates to work. For example there's one for a public function..'pubf' then tab to expand however when I tab mine out it looks like this...
<pubf></pubf>
What's going on? Is there a setting I need to enable to get it to work?
Thanks
Just for a little more clarity:
Even though you're under the PHP branch, you still need to apply the abbreviation to an application. Click the "Define" link and check the PHP box.
It was a question of scope for the template, just needed to select the appropriate file types.
Try:
Settings / Emmet and changing the default 'Expand abbreviation with' from tab to say custom
Make sure the context is selected underneath your template text. There is a small 'Change' link there where you set the context. I had to choose all contexts.

IntelliJ IDEA 13.1.2 javadoc and tabs

I hate to ask such simple questions, but nothing I found so far helped me...
So, I've recently started using IntelliJ instead of Eclipse and there are 2 things that really bothers me...
1.) size of javadoc popup window - ok, so I finally get this little guy to pop-up whenever I need it, but it's so small I have to use scroll every single time... and that's pretty anoying when I'm working with unknown libraries...
2.) tabs == spaces - maybe some of you like this, but I don't... Eclipse was treating tabs as tabs and not spaces... I tried to change settings but with no result... or is that maybe connected with project I'm working on? (meaning, if, at the start of a project, setting were such that tabs == spaces and now changes are not applied to it)
Sorry for stupid question but, as I said, nothing I found so far helped me...
1) Just resize the window with your mouse. It will retain the size the next time it opens. You can also click on the gear icon in the upper right corner and adjust the font size. Again, it will retain the size on subsequent use.
2) I'm assuming you make the change to the "Use Tab Character" option on the "Tabs and Indents" tab for all file types and saved the Code Style. After that, you need to run the Reformat Code action (Ctrl+Alt+L or Code > Reformat Code from the menu or Reformat Code from the context menu (i.e. right-click) in The Project Tool window or Navigation Bar). IDEA retains the previous formatting (so spaces in this case) until you run a reformat on the project (or a part of it).
If you have multiple projects already created, for each one, you will need to go into File > Settings > [Project Settings] > Code Style and set the Scheme (and then do a reformat). While the Scheme definition is saved IDE wide, the scheme to use is set per project (which makes sense since an Apache Open Source project you are working on may have different code style requirements than the projects you do at work vs the ones you do for fun).
Finally, you will also want to go into File > Other Settings > Default Settings > [Template Project Settings] > Code Style and make sure your saved code style scheme (with the use tab option) is set so that new projects use that scheme when they are created.

Is there a way in Intellij IDEA to see the name of the method the current line belongs to?

In our code base there are a few very long methods (several pages worth of code). When reading the code, it would sometimes be good to be able to see the name of the method the current line belongs to, without paging up to the beginning of the method. Is this possible in Intellij IDEA? I am using Intellij IDEA 7.0.3.
You can use View | Context Info (Alt+Q, Ctrl+Shift+Q on Macs). It will display a pop-up on the top of the editor with the current context information (class/method signature).
IntelliJ 2018
This is shown by default at the bottom.
Unfortunately, the method is shown only by name (not including the parameters). If a method is overloaded you won't know for sure where you are.
If you want to move it from bottom to top, go to File > Settings... > Editor > General > Breadcrumbs > check Top:
In the structure panel select the "Autoscroll from source" option.
This way when you place the cursor inside any method the structure panel will show which method you're in.
Intellij now has support for breadcrumbs. Go to settings > appearance and tick "Show breadcrumbs". In this way you can view class/method name without Alt+Q.
For some reason (Alt-Q) wasn't consistent in Android Studio for me. I find (Ctrl-F12) to be pretty satisfactory for this purpose (Navigate|File Structure) though it can be a little laggy in larger files. And by pressing the hotkey again it will populate the list with all the inherited methods as well.