Is there a way to turn off naming suggestions in a code snippet? - autocomplete

I'm writing Selenium page object classes in Java in Visual Studio Code. I created a custom code snippet that, when entered, looks more or less like this:
public WebElement ELEMENTNAME() {
return driver.findElementByCssSelector("CSSSELECTOR");
}
After I enter the snippet name and hit Tab, ELEMENTNAME gets the focus. I type the element name I've picked, such as ConfirmButton, and hit Tab...whereupon I find that my method now has the name ConfirmButtonElement, because VS Code decided to accept its own naming suggestion instead of what I typed.
How can I turn this "feature" off?
Usually VS Code's autocomplete suggestions are helpful, so I don't want to disable them entirely. But I definitely want to disable them in the case of naming things. Is there a way to do that?
(I'm not sure whether the behavior comes from VS Code itself or from an extension such as the Red Hat Java extensions.)

1. Extension to blame: It is actually happening because of Microsoft Java Extension Pack. Though it also includes the Red Hat Java Package
2. To disable this package: You can navigate to Extensions tab in VScode and search for Microsoft Java Extension Pack and click disable package.

I don't know when this may have been added to vscode, but have a look at:
// Control whether an active snippet prevents quick suggestions.
"editor.suggest.snippetsPreventQuickSuggestions": true,
true is the default, try false.

Related

IDE shortcuts - intelij IDEA to VSC

In intellij Idea, I could type "psvm" for a main method, and "fori" to get a for loop, and "sout" to get a system println, is there a way to customize intellisense in visual studio code to get the same behavior?
VSCode has many extensions that provide "snippets", shortcuts for code segments like you mentioned. The C/C++ extension which you might already have installed provides some for C++, such as main for a main method and for for a for loop. If you have the extension installed, snippets work exactly like other intellisense suggestions; you can simply type them and then press enter or tab to apply them.
You can also look for other snippet extensions by searching for #category:"Snippets" in the extension section.

How to disable "Run|Debug" line in vscode?

I am currently using Flutter with Dart. How do I permanently disable this annoying "Run|Debug" line in vscode?
That Run | Debug is not built-in to vscode. It must be contributed by one of your extensions. These seem like likely culprits:
Dart: Show Main Code Lens
// Whether to show CodeLens actions in the editor for quick running/debugging scripts with main functions.
Dart: Show Test Code Lens
// Whether to show CodeLens actions in the editor for quick running/debugging tests.
In case people get here because there is a Debug or Run in their package.json, that is a separate issue and answer, see https://stackoverflow.com/questions/62358131/how-to-disable-debug-from-showing-in-package-json/62368407?r=SearchResults&s=1|57.9327#62368407
Just disable Enable Code Lens in jest plugin.
It's very annoying! When you write test code, small Debug text shows on top of a test (above it method) when it fails.
During programming, it constantly shows and hides, causing lines of code move up and down a bit. It's terrible experience. Fortunately, easy to disable.
After disabling it, we still have test status feedback:
In VSC settings, search for "Pester Code Lens".
You can disable the first option.
Disable Pester Code Lens
Add this line to your settings:
"editor.codeLens": false,
Or do this in settings:
For Java Extension paste this in your settings.json file
"java.debug.settings.enableRunDebugCodeLens": false
you just open your vs Code Setting -> Text Editor -> Code Lean [Check mark this Box]

VSCode not showing function parameter list in Dart code

When I edit JavaScript code, VSCode immediately show me a popup with a list of parameters as soon as I have typed a function name followed by (.
When editing Dart code this is not the case. Here I have to use the mouse to hover over the function name to show a popup with information about the function.
Is this normal behaviour? Are there any way to change this behaviour? Does anyone know a shortcut to show the popup?
This is controlled by a VS Code user setting in the Dart extension (dart.triggerSignatureHelpAutomatically). It's not on by default because there are some quirks (that I don't remember exactly off the top of my head).
There's work in progress to move the extension to using the LSP protocol which will push some of this functionality into the Dart analysis server, which may make it easier to make some functionality like this more reliable (since more info is available in the language server than is currently exposed to the VS Code extension).

Method List in Visual Studio Code

I've recently started using the Visual Studio Code editor. I'm really loving it, but there's one critical feature (for me) that I haven't been able to find. Is there a method list, similar to the Navigator in NetBeans or Member dropdown in Visual Studio?
Yes, there is the workbench.action.gotoSymbol command. On Windows and Linux it's set to CTRL+Shift+O by default, on Mac it's Cmd+Shift+O.
If this command isn't available for the file types you are working with then you should take a look at the VSCode extensions. Not all languages support this feature.
Update: As stated in the comments by #jeff-xiao this extension is Deprecated and it's now a built in feature of Visual Studio code. It should be available at the bottom of file explorer as "Outline" view.
Previous text:
There is now an Extension that supports this. Code Outline creates a panel in the "Explorer" section and for JavaScript, will list variables and functions in a file. I've been using this for a while now and it scratches the itch I had. Other commenters have mentioned it supports Python and PHP well.
It still seems to be in development but I haven't had any issues. Development version available on GitHub. If you're the author reading this - thanks!
This is how it looks:
If Code Outline is not visible, you can show it by:
Invoke Code's Go to symbol command:
macOS: cmd+shift+o (the letter o, not zero)
Windows/Linux: ctrl+shift+o
Typing a colon (:) after invoking Go to symbol will group symbols by type (classes, interfaces, methods, properties, variables). Then just scroll to the methods section.
In 2020 version of VSCode
Cmd+P
# - Find symbol across files
# - Find symbol within file
#: - Group symbols within a file
In VSCode 1.24 you can do that.
Right click on EXPLORER on the side bar and checked Outline.
There is a new release that can do that!
Check here the latest release notes regarding code outline
UPDATE: The extension features are now built-in and the extension itself is now deprecated
I have found this extention: Code Outline.
This is how it looks like:
I believe that is what you have been looking for.
There's no such feature today,
the CTRL+SHIFT+O == CTRL+P # doesn't work for all languages.
As a last resort you can use the search panel - although it is not so fast an easy to use as you'd like - you can enter this regex in the search panel to find all functions:
function\s([_A-Za-z0-9]+)\s*\(
For PHP users :)
Make sure you have 'PHP Symbol' plugin then you can get all methods and class in 'OUTLINE' Sidebar's Bottom.
Press ⌘ command + ⇧ shift + O in "macOS" or Ctrl + Shift + O while using "Windows"
OUTLINE:
#Symbol:
For python in Explorer View, click on OUTLINE as below:
Visual Studio Code market place has a very nice extension named Go To Method for navigating only methods in a code file.
Hit Ctrl+Shift+P and type the install extensions and press enter
Now type Add to method in search box of extensions market place and press enter.
Click install to install the extension.
Last step is to bind a keyboard shortcut to the command workbench.action.gotoMethod to make it a real productivity thing for a developer.
Watch this link: https://code.visualstudio.com/updates/v1_40#_type-filters-for-outline-and-breadcrumbs
Explorer -> OUTLINE, you can choose what you want to show (only methods and functions in your case) and the result is similar to Netbeans:
Open symbol by name :
CTRL+T
might be what you are looking for. Works perfectly with my TypeScript project.
It is an extra part to the answer to this question here but I thought it might be useful. As many people mentioned, Visual Studio Code has the OUTLINE part which provides the ability to browse to different function and show them on the side.
I also wanted to add that if you check the follow cursor mark, it highlights that function name in the OUTLINE view, which is very helpful in browsing and seeing which function you are in.
ctrl+shift+o // This should work for javascript files by default
For PHP install the extension PHP SYMBOLS
FOR PYTHON install the extension PYTHON
On Reload, this will work fine
in-built code OUTLINE available now with VS code
There is a plugin called show functions which lists all the function definitions in a file. It also allows you to sort the function so can search them easily.
CTRL+F12 (CMD+F12 for Mac) - opens for me all methods and members in PHP class.
For find method in all files you can press CTRL + P and then start search with #
example : #signin
Take a look at Show Functions plugin.
It can list functions, symbols, bookmarks by configurable regular expressions. Regular expressions are a real saver, expecially when you're not using a mainstream language and when CodeOutline doesn't do the job.
It's ugly to see a split window with these functions (CodeOutline seems to be better integrated) but at least there's something to use
If you are using typescript you can use this extension "Code navigator for typescript".
I have been trying it and found it useful to list my typescript class methods.

Visual Studio 2005 - Missing feature 'Code outline' (eclipse) or 'Defs' (SlickEdit)

I mostly use SlickEdit and eclipse while working on embedded systems. Once in a while I need to use Visual Studio, and I terribly miss this feature that is known by different names in different editors. Basically you get a small window of 'outline style' code summary on the side (showing just the function names and optionally the static and globals at the top). You click an item on this little window and your cursor in the main editor window magically jumps to that item location. Here is how it looks like in SlickEdit:
http://sites.google.com/site/fractalspace/tmp1
Anyone knows what I am talking about ?
Any 'pointers' will be much appreciated :)
Thanks.
Take a look at the DPack addin
and more specifically at the Code Browser feature