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.
Related
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.
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.
Does VS Code (I currently use v1.8.1) has any shortcut like ctrl+q in eclipse?
It returns your cursor to the place where you stopped writing code(very useful for fast code browsing)
and it is different to alt+left which navigate backward
EDIT: I have found that this extension should do that you're asking. I suggest trying it out.
Original:
Out of the box in VS Code, this command does not exist. The list of default shortcuts can be found here, or you can open the keybindings settings in VS Code (ctrl+k, ctrl+s on Windows) and see which commands are available.
If you'd like to suggest this as a feature, you can open a new issue on GitHub or consider creating an extension.
If I understand correctly, you want a command that will move the cursor to where the last edit in a document was made.
This should be possible using an extension that listens to document change events and records the position of the cursor. Then, when the command is issued, it sets the editors cursor to that saved position.
You can also try "Eclipse Keymap" from Alphabot Security, has a lot of eclipse bindings.
I don't believe there is a built-in way to do this, but you could work around it by using an extension such as https://marketplace.visualstudio.com/items?itemName=alefragnani.Bookmarks .
Is there a way to quickly navigate through large files with multiple functions?
Something like class view in VS ?
Yes, there is the workbench.action.gotoSymbol command also known as outlining. Its default shortcut is CTRL+Shift+O.
If you have an extension installed which supports this command for the current file type then a list of methods, classes and maybe other symbols for the current file will drop down which allows you to jump to their definitions.
Yes, there is now a built-in Outline View in VS CODE
There is a built-in Outline View in Vscode (as other answer said)
There is also [outline-map] https://marketplace.visualstudio.com/items?itemName=Gerrnperl.outline-map
it collapses the object/hierarchy automatically, & expands as you scroll to it.
(recommended, more usable than the built-in one)
(or just find other ones in Vscode Extension Marketplace)
I'm used to the sublime text 3 editor.
It has many handy features.
take the code snippets for example,
Once you type begin then press TAB
It will generate the corresponding code block
begin
rescue Exception => e
end
And the plugin All Autocomplete
It can show the auto-complete hint for all opened files.
For example, if you have a variable name called taiwan_is_awesome
then you can get the autocomplete in other files.
Does Rubymine has the above features ?
If yes, what's the corresponding keymap ?
It's important for me to use those features.
THanks
Once you type begin then press TAB
It's called "Live Templates".
"Live templates (or code snippets) allow you to insert frequently-used constructions into your code. These can be conditions, blocks, loops, and so on."
You can manage bundled and create new ones at Settings/Preferences | Editor | Live Templates.
Here is a good "how to use" tutorial with screenshots: https://confluence.jetbrains.com/display/PhpStorm/Live+Templates+%28Snippets%29+in+PhpStorm -- it's for PhpStorm but exactly the same functionality is available in RubyMine.
UPDATE: 2022-11-15
The above tutorial link now automatically redirects to the corresponding Help page for PhpStorm.
Here is the same official Help page but for RubyMine that shows how to use and create them: https://www.jetbrains.com/help/ruby/using-live-templates.html
The setting you want to make RubyMine code completion work like All Autocomplete in Atom & ST3 is called "Autopopup code completion".
Solution:
Settings > Editor > General > Code Completion > "Autopopup code completion"
Note: there is another type of code completion called "Hippie Completion".
However, it works differently than "All Autocomplete". In RubyMine "Hippy Completion", you start typing text, and then you have to "guess" when RubyMine has enough text to figure out the completion you want. Then you hit ⌥/ (on the Mac). If RubyMine guesses right, it will autocomplete correctly.
I greatly prefer the "All autocomplete"/"Autopopup code completion" method, but just thought I'd mention this alternative.