Note, this article is not finished! You can help by editing this doc page.
Using Replit.com
Replit is a very accessible online environment that allows you to create applications in C++. An important advantage is that it has an interactive console.
Creating an account
For some time now, Replit.com has required the creation of a free account on their site. You can do this by following this link: https://replit.com/signup
Then complete the information below:
![Creating a Replit account](/img/tutorials/tools/replit/sign-up-form.png)
Creating a project
Once you are logged in, use the C++ application pattern we have prepared by going to this link:
Click Fork repl:
![Creating a new project from template](/img/tutorials/tools/replit/fork.png)
You can also create a default C++ project that the Replit website offers, but at the moment only Clang 7 will be available, which does not support C++20.
Using the editor
Once you have created your project, you will be transferred to the code editing mode:
![C++ code editor](/img/tutorials/tools/replit/editor-view.png)
The main view is made up of three panels:
Panel | Contents |
---|---|
Left | tools view, by default file view 🗃 |
Middle | code editor ✏ |
Right | console 🖥 and system terminal (shell) |
Running the program
▶ At the top you will find the Run button that starts the application.
![Run button](/img/tutorials/tools/replit/run-button.png)
Before the program can be executed, its code must be compiled. This means that at the beginning you will see a command to compile the code in the console.
- ✔ If the program code is correct, the line below will show the result of its operation.
- ⚠ If the compiler detects any non-fatal problems on the code, it will warn you before running the program.
- 🔴 If the code contains errors, the program will not be compiled or executed.
- ✔ Correct code
- ⚠ With a warning
- 🔴 With an error
![Compilation and running a valid code](/img/tutorials/tools/replit/run-command-ok.png)
![Compilation and running a code with warnings](/img/tutorials/tools/replit/run-command-warning.png)
![Compilation failed because of an error](/img/tutorials/tools/replit/run-command-error.png)
Editing the source code
This section requires improvement. You can help by editing this doc page.
This environment supports all the basic functions that a beginner needs.
![Code editor view](/img/tutorials/tools/replit/only-editor.png)
Keyboard shortcuts
Replit is based on the same editor as Visual Studio Code, and therefore has similar keyboard shortcuts. In addition to the standard ones, it's worth testing these:
Shortcut | Description |
---|---|
Ctrl + Shift + P or F1 | Open a command window |
Drag with middle mouse button | Place multiple cursors on adjacent lines |
Alt + LPM | Add a new cursor at the click location |
Ctrl + / | Toggles comment on the selected fragment |
Alt + 🔼 | Move the current line up one line |
Alt + 🔽 | Move the current line down one line |
Shift + Alt + 🔼 | Duplicates the selected lines upwards |
Shift + Alt + 🔽 | Duplicates the selected lines downwards |