您现在必须知道Visual Studio Code。之所以如此,是因为我们前段时间在一篇文章中已经讨论过它。现在,在本文中,我们将讨论如何使您编写的程序变得更好。对我来说,“更好”是指无错误、优化代码的概念,这将导致各个项目的部署和执行更顺畅。我们将在本文中介绍有关在IDE上编写一些代码的所有内容。(IDE)但在此之前,我们应该介绍Visual Studio Code更好地支持的所有语言和技术。
如何在 Visual Studio Code上编写和增强您的第一个程序(Studio Code)
此 Visual Studio Code初学者教程将向您展示如何编译或编写您的第一个程序或代码。Microsoft在(Microsoft)Visual Studio Code中添加了对扩展的支持。这些扩展有助于增强和优化PHP、C、C++ 等语言的代码!
Visual Studio Code(Studio Code)支持的语言
根据Visual Studio Code官网公布的网页, (Studio Code)IDE支持的主要语言如下。它们包括 C++、C#、CSS、Dockerfile、Go、HTML、Java、JavaScript、JSON、Less、Markdown、PHP、Python、Sass、T-SQL和TypeScript。
现在有了这个,你可以获得一些语言特性来帮助你编写更好的代码。这个更好的代码在我们上面讨论的轨道中是相似的。因此,通过对众多扩展的支持,我们获得了对以下内容的丰富支持:
Syntax highlighting and bracket matching, Smart completions (IntelliSense), Linting and corrections, Code navigation (Go to Definition, Find All References), Debugging and Refactoring.sc
当IDE(IDE)支持该语言或文件扩展名时,您将在右下角的状态栏中 (Status Bar )看到该特定语言的名称 。否则,它会向您显示降价(markdown)或纯文本(plaintext )。
例如:
上图是 IDE未(does not identify)将文件识别为已知类型的情况。因此(Hence),它被称为 纯文本。(Plain Text.)
现在,让我们看看如何安装和使用这些扩展来充分利用它们的功能。
如何在 Visual Studio Code上安装扩展(Studio Code)
因此,在打开 Visual Studio Code(Studio Code)的第一步中,您可能会看到一个类似于以下代码片段的屏幕。
之后,单击 左侧垂直菜单上的扩展 按钮,如下面的屏幕截图所示。(Extensions )
然后您将看到一个新面板从左侧滑出。在面板的搜索(Search)栏中,搜索您想要扩展的语言或服务。我将搜索PHP的扩展,因为我将对其进行演示。
从作为搜索结果获得的列表中,选择最适合满足您需求的列表。如果单击扩展程序列表,您将获得更多详细信息,例如描述、开发人员名称、功能、大小、兼容性等。
一旦你点击了安装 (Install )按钮,你就可以开始了!
现在,当我在 Visual Studio Code上安装(Studio Code)PHP IntelliSense 扩展(PHP IntelliSense Extension)时,它开始显示智能建议和不同语法的自动完成。因此(Hence),这将减少出错的机会,并使您的应用程序的执行和部署顺利。
此处插入了IntelliSense(IntelliSense)处理PHP文件的实时示例。
如果您想试试我现在所做的,只需按照这些快速步骤操作即可。
安装 Visual Studio Code(Install Visual Studio Code) ,然后按照上述步骤中的说明搜索或获取PHP扩展,或点击此链接(PHP)marketplace.visualstudio.com。
现在创建一个新文件并将其保存在 文件的.php 扩展名中。
<?php
echo "This is Ayush from TheWindowsClub.com";
?>
保存(Save)并将文件移动到 XAMPP 的 htdocs 文件夹或WAMP 的WWW 文件夹。
现在,最后打开您最喜欢的 Web 浏览器并输入文件的本地URL。然后你会看到这样的输出。
希望(Hope)你觉得它很容易理解。
Enhancing code on Visual Studio Code with the help of Extensions
You must be aware of Visual Studio Code already by now. This is so because we already talked about it in an article a while ago. Now, in this article, we are going to talk about how to make the programs that you write better. For me, ‘better’ refers to the notion of error-free, optimized code which will lead to smoother deployment and execution of the respective project. We will be covering everything about writing some code on the IDE in this article. But before that, we should cover what all languages and technologies are supported better by Visual Studio Code.
How to write & enhance your first program on Visual Studio Code
This Visual Studio Code tutorial for beginners will show you how to compile or write your first program or code. Microsoft added support for extensions in Visual Studio Code. These extensions help to enhance and optimize your code for languages like PHP, C, C++ and more!
Languages supported by Visual Studio Code
According to the webpage published on the official website of Visual Studio Code, the following are the main languages supported by the IDE. They include C++, C#, CSS, Dockerfile, Go, HTML, Java, JavaScript, JSON, Less, Markdown, PHP, Python, Sass, T-SQL, and TypeScript.
Now with this, you get some language features that help you write better code. This better code is similar in the track of what we talked about above. So, with support for numerous extensions, we get the rich support for the following:
Syntax highlighting and bracket matching, Smart completions (IntelliSense), Linting and corrections, Code navigation (Go to Definition, Find All References), Debugging and Refactoring.sc
When the language or the file extension is supported by the IDE, you will see the name of that particular language in the Status Bar on the bottom right corner. Else, it will show you markdown or plaintext written.
For example:
The above image is when the IDE does not identify the file as a known type. Hence, it is mentioned as Plain Text.
Now, let us take a look at how to install and use these extensions to leverage the full advantage of their capabilities.
How to install Extensions on Visual Studio Code
So, in the first step when you open Visual Studio Code, you might see a screen somewhat similar as shown in the snippet below.
After that, click on the Extensions button on the left side vertical menu as shown in the screenshot below.
Then you will see a new panel sliding from the left side itself. In the Search bar of the panel, search for the language or service you want an extension for. I will be searching for an extension for PHP because I will be demoing it.
From the list that you get as search results, select the one that is most suitable to fulfill your needs. If you click on the listing of the extension, you will get more details like description, developer’s name, features, size, compatibility, and more.
Once you hit on the Install button, you are good to go!
Now as I installed the PHP IntelliSense Extension on Visual Studio Code, it starts displaying smart suggestions and auto-completion for different syntax. Hence, this will decrease the chances of an error and will make the execution and deployment of your application smooth.
The real-time example of IntelliSense working with a PHP file is inserted here.
If you are curious to try out what I did now, just follow these quick steps.
Install Visual Studio Code and then, search or get the extension for PHP as instructed in the steps above or follow this link marketplace.visualstudio.com.
Now create a new file and save it in .php extension for the file.
<?php
echo "This is Ayush from TheWindowsClub.com";
?>
Save and then move the files to the htdocs folder of XAMPP or WWW folder of WAMP.
Now, finally open your favorite web browser and enter the local URL for your file. Then you will see an output like this.
Hope you find it easy to understand.