IntelliSense is Microsoft's term for a feature that provides code
completion services as you type.
You might see this type of feature generally referred to as code
completion or code hinting. Whatever you want to call it,
it's a tremendous help when writing code.
It not only saves you keystrokes, but you also don't have to
remember the exact name of method you want to call
or how many and what type of parameters they accept.
I'll give you a quick demo in this JavaScript file.
We can see IntelliSense in action
if I start typing some code that refers to the global
document object.
There's a language service running inside VS Code that understands
JavaScript, its built-in objects, and any
objects I've created.
As soon as I type a so-called trigger character,
a dot in JavaScript, I get a pop-up showing properties
and methods that exist on that object.
If you happen to dismiss this pop-up accidentally,
you can bring it back by pressing Ctrl plus the space bar.
This could potentially be a long list,
but as you continue to type, the list will be filtered based
on the characters you enter.
Let's imagine I want to get a reference to an element
on the document, but I don't remember the
exact method name.
I'll type get and the list of choices is filtered to those
that include that word.
I'm pretty sure I want this method named getElementById,
but I'll first highlight it, and I'm shown a second pop-up with
more information about the method.
This lets me know the method accepts a single string parameter
and returns a reference to the first object with the
specified ID value.
I can add the rest of the function name to my code by pressing either
"Tab" or "Enter" while the function is highlighted.
As soon as I type an opening parentheses for the parameters,
I get another IntelliSense pop-up with more information about
the expected parameter.
These little pop-ups can be very helpful.
They save you the trouble of remembering exact property
and method names and can also save you time looking
through the documentation to determine the expected parameters
and return values.
I'm going to delete this line of code for now.
Visual Studio Code includes IntelliSense out of the
box for JavaScript, TypeScript, HTML,
CSS, and several other languages.
It also will perform some basic word-based matching on just
about any language.
However, for the best possible experience,
search for and install any available extensions for the
languages you plan to use.
I showed you how to do that in the previous chapter.
I'll quickly go back to my list of installed extensions.
I'll click on the Python extension I installed earlier.
The first feature mentioned about this extension is its support
for IntelliSense.
The Pylance extension installed as a dependency
includes a Python language service that's going to deliver an
excellent IntelliSense experience for Python developers.
The last thing I want to mention about IntelliSense is that
it's very configurable.
I'll use the command palette to open the settings editor.
I'll expand the text editor section on the left.
I'll then click on "Suggestions."
There are far more options in here than you would probably expect.
Everything from how and when suggestion pop-ups appear to how
suggestions are filtered, and even precisely what types
of suggestions to include.
If you occasionally find all the IntelliSense pop-ups
a bit distracting as I do, try tweaking a few
of these settings. You can probably fine-tune it to
only show you the things you're interested in
while keeping the giant flashing pop-ups to a minimum.
In any case, I find IntelliSense incredibly helpful, and I wouldn't
want to have to write code without it.
After you've written that code, there will likely come a day when
you need to refactor it.
Up next, we'll look at some of the refactoring support included
in VS Code.