IDE
Brief​
An IDE (Integrated Development Environment) is like a text editor, but way more powerful! It has a lot of additional features that will help you write, run and debug your code!
I personally use and recommend Visual Studio Code (VSCode for short).
Extensions​
There are many extensions that can help you! Check out the recommended extensions for your language or discover what other people use.
Here are some great extensions for VSCode that I recommend:
- cpptools-extension-pack: The Basic C++ extensions
- BuildOutputColorizer: To colorize the output of the compilation and highlight error messages.
- code-spell-checker: A great spell checker.
- markdown-all-in-one: To preview your markdown and get help during edition (e.g. it can automatically generate a table of content).
- vscode-great-icons: Nice icons for many file types (.cpp, .hpp, CMakeLists.txt, etc.).
- vsliveshare: This allows you to work remotely with your teammates in one single editor. It is amazing to work together!
- cmake-language-support-vscode: To provide autocompletion and formatting for CMake.
Quick actions​
Below are a few of the most important things that an IDE will help you with; I will demonstrate them using VSCode but rest assured that any other IDE will have the same functionalities. Please note that most of these actions are only available if
cpptools-extension-pack is installed in your VSCode.Rename​
Right-click on any name and choose Rename Symbol (or put your text cursor on a name and use the shortcut F2).
It is better than doing a "Find and Replace" because "Rename Symbol" is content-aware; e.g. if you rename a class called "Point" it will not affect another class called "Point2D".
Go to definition​
This will take you directly to the definition of the variable / function / class. This is the functionality I use the most to move around my code.
And if you want to stay focused on the portion of code you are currently editing you can also Peek at the definition and it will open a small window inside your current file.
Go to symbol​
This allows you to quickly jump to a method in a file; the shortcut is CTRL + SHIFT + O and then you can type in what you are looking for. It is also super useful to outline the structure of a file.
Go to file​
If you know which file you want to open it is blazing fast to press CTRL + P and type what you need.
Switch between .hpp and .cpp​
Use ALT + O to quickly switch between the header and the implementation file. Very useful when you are writing code for a class.
Find all references​
This allows you to find all the places where a symbol is used. Simply right-click on a variable or method and select Find All References to get this panel to open. Just like the Rename Symbol action it is context-aware and is supposed to only return the correct variable (if another one has the same name, it won't show up).
Search for a word in the current file​
Useful to find you way around, simply press CTRL + F to open this popup and search what you need. The arrow on the left allows you to rename the occurrences you found, which can be useful.
Search for a word in the whole project​
If you need to find something fast and easy, run CTRL + SHIFT + F, enter the object of desire and press enter. The VSCode search bar is awesome and won't let you down, you can even batch-rename things there! As a side note, it is also great to be able to limit the search to a specific folder, the option is available when you press the three dots on the right.
Launching the project​
Once you have the CMake setup done (either by using the template project or by doing it yourself) you can build the project by pressing F7 or run it using CTRL + F5.
Going further​
TODO link to lesson Master your IDE