编辑器
Remix使用Monaco编辑器。VSCode也使用相同的编辑器。
Remix每5秒保存一次当前文件。
Remix 编辑器会高亮显示 Solidity、JS和TS 中的关键词。
编辑器会显示来自其他插件的信息。
编辑器的主要目的当然是编辑代码。但它还可以与其他插件一起使用,特别是 Solidity 编译器和调试工具。
Solidity编译器将在有问题行时,在Editor边栏中显示警告和错误信息。
调试程序时,可在Editor边栏打上断点。
在Debugger中逐步执行代码时,相关代码将在Editor中突出显示。

常规操作
文件以选项卡形式打开。当选项卡太多无法显示时,使用鼠标滚轮可以水平滚动选项卡。

The play button works on the active tab. If a Solidity file is active, clicking Play will compile it. If a TS or JS file is active, Play will run the script.
左上角的放大镜图标(+/-)可增加/减小字体大小。
编辑器最右侧的小型文本可点击跳转到某个部分。
TypeScript
编辑器和脚本运行程序支持TypeScript,这意味着您可以编写TypeScript代码,并在Remix中进行自动完成和直接运行。如上所述,TS具有语法高亮功能。
默认工作区包含示例TypeScript文件。
编辑器和自动编译
When auto-compile is enabled (in the Solidity Compiler), compilation will occur each time the current file is changed, or another file is selected.

自动补全
在编辑器中开始输入时,Solidity代码的自动补全会发生。编译器将在后台运行,并处理您拥有的任何导入。您将看到这些导入出现在文件资源管理器中的.deps目录中。

小技巧
If you start with a Solidity file that contains errors, the Compiler might not be able to compile it. In that case, the Editor's autocomplete features will not fully work until after the file is successfully compiled. After that, autocomplete will work even if there are errors, but only for the elements the Compiler already understands. For example, if you add a new function in a file that contains errors, autocomplete will not be able to find that function because it can’t compile the file.

导入自动补全
编辑器的自动补全功能将提供引入OpenZeppelin合约、Uniswap合约以及当前工作区中所有文件路径的选项。

因此,当选择@openzeppelin时,您将会得到以下内容:

Uniswap也一样

错误和警告
如果编辑器中没有显示任何错误或警告,那么您可以确定文件已经成功编译。使用波浪线来显示错误信息。红色的波浪线表示有一个错误,黄色的波浪线则是一个警告。

将鼠标悬停在波浪线上会显示编译器的消息。

选项卡和文件资源管理器还会显示文件是否包含错误或警告。

导入的文件中出现错误
如果文件中导入的其中一个文件存在错误,编辑器也会触发一个错误。你的主要文件可能无法编译,但是你将立即看到有问题。
在文件资源管理器中悬停在错误编号上
一个文件中的错误数量也报告在了 文件资源管理器 中。悬停在数字上,它表示 错误/警告 的数量,并且将显示来自编译器的信息。

Quick Fixes for common mistakes
The Remix editor offers solutions to the following missing keywords & code:
License
Pragma
Visibility
Mutability
Data Location (storage, memory, etc)
Add virtual or override
Marking a contract abstract
A Quick Fix option is available when there is a blue dot in Editor - like in the image below.
In this example, the license has been left out. After compilation, a warning is triggered and a Quick Fix blue dot appears.

When you click on the blue dot, a popup menu appears. In this case of a missing license, these are the options:

If you can’t get the Quick Fix blue dot to appear, try clicking on the number for the line where the error occurs.
Gas 估算
Gas估算显示在声明函数的同一行。

构造函数的Gas估算也会被显示,包括两个组成部分:创建成本和代码存储成本。
转到定义和引用
定义
通过右键单击,您可以转到定义。您还可以使用快捷方式进行操作。
您还可以右键单击导入语句的文件名并跳转到该文件。

您还可以在编辑器中“查看”内联定义。然后,通过双击行右侧来跳转到定义。
引用
通过右键单击,您可以显示所有的引用。您也可以使用快捷方式进行操作。

双击行右侧即可跳转到相应的引用。

突出显示的引用
在编辑器中,引用会被突出显示。

悬停提示
当您将鼠标悬停在带有定义的术语上时,定义将弹出。当您将鼠标悬停在触发错误(下划线为红色波浪线)的代码上时,会显示错误消息。

文件出现错误时会变成红色
当一个文件包含错误时,它的名称将在“文件资源管理器”中和编辑器顶部的选项卡上变为红色。
有关编辑器更新的更多信息,请参阅此文章:Remix 编辑器的重大更新