Visual Studio Code(VS Code)入门

Visual Studio Code is a popular text editor or code editor to write queries and codes for developers. It is popularly known as VS code. It can highlight and format the code for quick development and understanding purposes.

Visual Studio Code是一种流行的文本编辑器或代码编辑器,用于为开发人员编写查询和代码。 它通常被称为VS代码。 它可以突出显示和格式化代码,以便快速开发和理解。

Visual Studio Code的有用功能 (Useful features of Visual Studio Code)

We may find several features in the VS code as a good text editor.

作为一个好的文本编辑器,我们可能会在VS代码中找到一些功能。

  • Cross-platform support: VS Code is available on Windows, Linux, and macOS operating systems. You can quickly install it on your favorite platform 跨平台支持: VS Code在Windows,Linux和macOS操作系统上可用。 您可以将其快速安装到您喜欢的平台上
  • Syntax highlighting: As a developer, you may write code in different languages such as t-SQL, PHP, AWS CLI commands, Python, PowerShell, JavaScript. VS Code can highlight language-specific syntax. You do not require to switch to multiple platforms for a specific language 语法突出显示:作为开发人员,您可以使用不同的语言编写代码,例如t-SQL,PHP,AWS CLI命令,Python,PowerShell,JavaScript。 VS Code可以突出显示特定于语言的语法。 您不需要为特定语言切换到多个平台
  • Code indentation: VS code also supports for code indentation for different coding languages 代码缩进: VS代码还支持不同编码语言的代码缩进
  • Plug-in or extensions: It also provides several extensions to enhance the usability of the VS code. These extensions increase the capability of the VS code. You can have extensions for SQL Server, AWS, Python, keyboard shortcuts 插件或扩展:它还提供了几个扩展来增强VS代码的可用性。 这些扩展增加了VS代码的功能。 您可以具有SQL Server,AWS,Python,键盘快捷键的扩展
  • Tree view representation: It gives you a tree view or hierarchical interface to view your project files, codes. You can easily navigate through different sections using this 树视图表示:它为您提供树视图或分层界面,以查看您的项目文件和代码。 您可以使用此按钮轻松浏览不同的部分
  • Integrated terminals: Visual Studio Code provides an integrated terminal for your workspace. You don’t require to switch different windows to perform command-line tasks 集成终端: Visual Studio Code为您的工作区提供集成终端。 您无需切换其他窗口即可执行命令行任务
  • Display language: You can easily configure the desired language in this using the Language Pack extension 显示语言:您可以使用Language Pack扩展名轻松配置所需的语言
  • Color themes: You can easily customize it with different color schemes. You can quickly modify it as per your preference and environment 颜色主题:您可以使用不同的配色方案轻松自定义它。 您可以根据自己的喜好和环境快速修改它

Windows的VS代码安装 (Installation of VS code for Windows)

Navigate to Visual Studio Code URL and choose your desired platform to install the software. You can see the installer for Windows, macOS, and Linux in the below screenshot.

导航到Visual Studio代码URL,然后选择所需的平台来安装软件。 您可以在下面的屏幕截图中看到Windows,macOS和Linux的安装程序。

Download Visual Studio Code

For Windows, you get an option to download the 32-bit or 64-bit version.

对于Windows,您可以选择下载32位或64位版本。

Download options

Download the appropriate version and start the installation. Its installation is quick.

下载适当的版本并开始安装。 它的安装很快。

You can click on next for installation, but let me highlight the useful step.

您可以单击“下一步”进行安装,但让我突出显示有用的步骤。

In the setup additional tasks, you get options to integrate VS code with Windows explorer.

在设置其他任务中,您将获得将VS代码与Windows资源管理器集成的选项。

  • Add open the code action to the Windows explorer file context menu: You get an option to open a specific file in the VS Code in the right-click menu 在Windows资源管理器文件上下文菜单中添加“打开代码”操作:在右键菜单中的VS Code中,您可以选择打开特定文件。
  • Add open the code action to Windows explorer directory context menu: Suppose you get multiple scripts in a folder, it is not feasible to open each file individually. In VS Code, you can right-click on the folder, and it opens all files in a single click 在Windows资源管理器目录的上下文菜单中添加打开代码操作:假设您在一个文件夹中获得了多个脚本,则单独打开每个文件是不可行的。 在VS Code中,您可以右键单击该文件夹,然后单击即可打开所有文件。
  • Register code as an editor for supported file types: This option registers the visual studio code as a default editor for supported file systems 将代码注册为支持的文件类型的编辑器:此选项将Visual Studio代码注册为支持的文件系统的默认编辑器
  • Add to path

    添加到路径

Set additional tasks

VS Code的不同组件和功能 (Different component and features of VS Code)

Launch the Visual Studio code after installation, and the default screen looks like below. On the left side, you have an activity bar.

安装后启动Visual Studio代码,默认屏幕如下所示。 在左侧,您有一个活动栏。

Activity bar

This activity bar contains the following tabs.

该活动栏包含以下选项卡。

探险者 (Explorer)

This explorer is to open, browse, and manage the files. You can also use this as a notepad text editor or programing language code. You can open multiple files in an explorer.

该资源管理器用于打开,浏览和管理文件。 您也可以将其用作记事本文本编辑器或编程语言代码。 您可以在资源管理器中打开多个文件。

Explorer

You can split the files as per your requirements – Split Up, Split down, Split left, Spit right.

您可以根据需要拆分文件-拆分,拆分,向左拆分,向右吐。

Split options

For example, once you split down the files, it creates a new region for the split files. In the below screenshot, you get two files splits in the current window. It is useful when you want to compare two or more scripts together or want to reference another script.

例如,拆分文件后,它将为拆分文件创建一个新区域。 在下面的屏幕截图中,您在当前窗口中拆分了两个文件。 当您要将两个或多个脚本一起比较或要引用另一个脚本时,此功能很有用。

Multiple splits

Similarly, you can rearrange editors in multiple groups, split left, right, down in the same editor window.

同样,您可以在同一编辑器窗口中按左,右,下拆分多个组来重新排列编辑器。

Rearrange windows

搜索 (Search)

It is to search for a specific keyword in all the open files in the editor window. For example, suppose we want to replace the sys.databases with databases keyword in all open files. Enter the keyword and search it in all open editor files. You see each occurrence of the keyword in all editor files. It also shows line after keyword replacement, as highlighted below.

它是在编辑器窗口中所有打开的文件中搜索特定的关键字。 例如,假设我们要在所有打开的文件中将sys.databases替换为databases关键字。 输入关键字并在所有打开的编辑器文件中搜索。 您会在所有编辑器文件中看到该关键字的每次出现。 它还显示了关键字替换后的行,如下所示。

Search

源代码控制 (Source Control)

Visual Studio Code supports the integration of multiple Source Control providers such as TFS, Git, SVN.

Visual Studio Code支持集成多个源代码控制提供程序,例如TFS,Git,SVN。

(Run)

You can run the debugger using this tab. You can also customize the debug using a configuration file in JSON format.

您可以使用此选项卡运行调试器。 您还可以使用JSON格式的配置文件来自定义调试。

Source Control

延期 (Extension)

Visual Studio Code extends the functionality and features using the extensions. These extensions are free to download, install, and use. It provides various extensions for different programming languages, formats, keyboard shortcuts, cloud solutions. By default, it gives you the popular and recommended extensions. We will cover separately about the extensions in further articles.

Visual Studio Code使用扩展功能扩展了功能。 这些扩展可以免费下载,安装和使用。 它为不同的编程语言,格式,键盘快捷键,云解决方案提供了各种扩展。 默认情况下,它为您提供了流行和推荐的扩展。 我们将在后续文章中分别介绍扩展。

Extension

Once you open a specific file in the VS code, it gives you a recommendation as well. For example, if I open a T-SQL script, it suggests installing the mssql extension for this file type.

在VS代码中打开特定文件后,它也会为您提供建议。 例如,如果我打开一个T-SQL脚本,则建议为此文件类型安装mssql扩展名

mssql extension

小地图 (MiniMap)

VS Code provides a code outline feature to have a high-level overview of code, quickly navigate to a particular area. It is similar to the Scroll Bars feature you get in the recent versions of SQL Server Management Studio. You can refer to New feature in SQL Server Management Studio 2016 – Scroll bar for more details.

VS Code提供了代码概述功能,可以对代码进行高级概述,并快速导航到特定区域。 它类似于您在SQL Server Management Studio的最新版本中获得的“ 滚动条”功能。 您可以参考 SQL Server Management Studio 2016的新功能–滚动条 以了解更多详细信息。

You get the minimap on the right side of the code editor. We can remove the minimap from the View-> Show minimap.

您会在代码编辑器的右侧获得小地图。 我们可以从“视图”->“显示小地图”中删除小地图。

Minimap

面包屑 (Breadcrumbs)

Once you open any file in VS Code, it shows its current location on the top, and you can navigate quickly between files and folders. For example, for my script, it gives me the path SQL -> QA -> script name.

在VS Code中打开任何文件后,它将在顶部显示其当前位置,并且您可以在文件和文件夹之间快速导航。 例如,对于我的脚本,它为我提供了路径SQL-> QA->脚本名称。

Breadcrumbs

Suppose I want to take a step back and open the script in the SQL folder. You can click on the corresponding folder, and it gives you a list of files inside the folder. Click on the respective script to open in the query editor window.

假设我想退后一步,在SQL文件夹中打开脚本。 您可以单击相应的文件夹,它会为您提供该文件夹内文件的列表。 单击相应的脚本以在查询编辑器窗口中打开。

Breadcrumbs example

We can disable breadcrumbs using the View > Show Breadcrumbs command as shown below.

我们可以使用“ 视图” >“ 显示面包屑”命令禁用面包 ,如下所示。

Disable Breadcrumbs

命令面板 (Command Palette)

You can access all functions of the VS code using the Command Palette. It shows the various tasks, configurations along with the keyboard shortcuts.

您可以使用命令面板访问VS代码的所有功能 它显示了各种任务,配置以及键盘快捷键。

You can launch a command palette from View -> Command Palette. You can also use Ctrl+Shift+P key combinations.

您可以从“视图”->“命令面板”启动命令面板。 您也可以使用Ctrl + Shift + P组合键。

Command Palette

It sorts the functions in alphabetical order. You can search for a specific item as well.

它按字母顺序对功能进行排序。 您也可以搜索特定项目。

functions in Command Palette

禅宗模式 (Zen Mode)

You can focus on your code using the zen mode in the VS code. It hides the activity bar, status bar, sidebar, and you see code in full-screen mode.

您可以在VS代码中使用zen模式来专注于代码。 它隐藏了活动栏,状态栏,侧边栏,并且您可以在全屏模式下查看代码。

To open the zen mode, search for the View: Toggle Zen Mode. Alternatively, use the keyboard shortcut Ctrl+K Z.

要打开禅宗模式,请搜索“ 视图:切换禅宗模式”。 或者,使用键盘快捷键Ctrl + KZ。

Zen Mode

It brings the code in full-screen mode by hiding all bars. It helps you to focus on your development work—Press Esc to exit the zen mode in VS code.

通过隐藏所有栏,它将代码带入全屏模式。 它可以帮助您专注于开发工作-按Esc键以VS代码退出zen模式。

View output of Zen Mode

颜色主题 (Color Themes)

VS Code provides different color schemes to suit your preference and work environment. You can use the theme from the command palette. It supports different themes, as shown below.

VS Code提供不同的配色方案,以适合您的喜好和工作环境。 您可以从命令面板使用主题。 它支持不同的主题,如下所示。

Color Themes

互动游乐场 (Interactive Playground)

Visual Studio Code provides an interactive playground to try out its features. You can launch an interactive playground from the link on the Welcome page.

Visual Studio Code提供了一个交互式游乐场来试用其功能。 您可以从“欢迎”页面上的链接启动一个交互式游乐场。

Interactive Playground

You can also launch it from the Help > Interactive Playground.

您也可以从“ 帮助” >“ 交互式游乐场”启动它。

Launch Interactive Playground

You can learn about the useful VS code features in this interactive playground. It gives you a list of editor features such as multi-cursor editing, intelligence, line actions, rename factoring, code folding.

您可以在此交互式游乐场中了解有用的VS代码功能。 它为您提供了编辑器功能列表,例如多光标编辑,智能,行动作,重命名分解,代码折叠。

Interactive Playground examples

For example, let’s say we want to explore Multi-cursor editing. It explains the feature and instructs to practice in this interactive window.

例如,假设我们要探索多光标编辑。 它解释了该功能并指示在此交互式窗口中进行练习。

Multi-cursor editing

Similarly, scroll down, and you see the section for line actions.

同样,向下滚动,您会看到有关行操作的部分。

Line actions

For example, if we can copy a line and insert it at the above or below position using the shortcut key specified in the example. It is described well so that you can follow the steps and learn these productivity features.

例如,如果我们可以复制一行,并使用示例中指定的快捷键将其插入到上方或下方的位置。 对其进行了很好的描述,以便您可以按照以下步骤操作并学习这些生产力功能。

结论 (Conclusion)

In this article, we explored the useful features of the Visual Studio Code, aka VS Code, that serves the purpose of a lightweight and powerful source code editor. You can use it on Windows, Linux, and macOS. We will explore more on its features, extensions in the upcoming articles.

在本文中,我们探讨了Visual Studio Code(又名VS Code)的有用功能,该功能可用于轻量级功能强大的源代码编辑器。 您可以在Windows,Linux和macOS上使用它。 我们将在以后的文章中进一步探讨其功能和扩展。

翻译自: https://www.sqlshack.com/getting-started-with-visual-studio-code-vs-code/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值