Editing

Note

All editor features are disabled until you have chosen a CMake preset.

Explorer and File Management

The Explorer view in Visual Studio Code (VS Code) is a fundamental feature that provides a comprehensive overview and easy navigation of your project’s files and folders. Here is a quick summary of its key functionalities:

  • File Navigation : Allows you to browse, open, and manage the files and directories in your workspace. You can quickly locate and access any file within your project.

  • File Operations : Supports common file operations such as creating, deleting, renaming, and moving files and folders. These operations can be performed directly within the Explorer view.

  • Search Integration : Integrates with the search functionality, enabling you to search for files and content within your project. The search results can be viewed and accessed directly from the Explorer.

  • Version Control : Displays version control status for files (e.g., Git). You can see which files have been modified, added, or deleted, and access version control commands directly from the Explorer.

  • Drag and Drop : Supports drag-and-drop functionality for easy file management. You can drag files and folders to move or copy them within the project structure.

  • Context Menu : Provides a context menu with additional options and commands when you right-click on files or folders. This menu includes options for file operations, version control, and more.

  • File Preview : Allows you to preview files without opening them in a new tab. Clicking on a file in the Explorer will display a preview in the editor area.

  • Workspace Management : Displays and manages multiple workspaces. You can add or remove folders from your workspace and switch between different workspaces easily.

Overall, the Explorer view in VS Code is a powerful tool for managing and navigating your project’s file structure, enhancing productivity and efficiency in your development workflow.

Code Editor Features

Syntax Highlighting and Code Completion

Syntax highlighting is automatically enabled in Visual Studio Code based on the file extension and installed language extensions. To use code completion (IntelliSense) :

  • Start typing your code, and VS Code will display suggestions automatically.

  • You can trigger suggestions manually with Ctrl+Space (Windows/Linux) or Cmd+Space (macOS).

  • Use arrow keys to navigate suggestions and Enter or Tab to accept.

Code Navigation and Refactoring Tools

To navigate code efficiently:

  • Go to Definition: Right-click a symbol and select Go to Definition , or press F12 .

  • Peek Definition: Right-click and choose Peek Definition or press Alt+F12 to view the definition inline.

  • Find All References: Right-click a symbol and select Find All References , or press Shift+F12 to list all usages.

  • Rename Symbol: Place the cursor on a symbol, press F2 , enter the new name, and confirm to refactor across the project.

Advanced Editing Tools

Code Snippets and Templates

To insert code snippets:

  • Start typing the snippet prefix and select it from the IntelliSense suggestions.

  • Alternatively, press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS), type Insert Snippet , and select the desired snippet.

  • You can customize or add your own snippets by editing the snippets files via Preferences: Configure User Snippets .

Integration with Static Code Analysis

Static analysis tools (like ESLint, Pylint, or Cppcheck) can be integrated via extensions.

  • Install the relevant extension from the VS Code Marketplace.

  • Configure the tool settings in .vscode/settings.json or project config files.

  • Issues and warnings appear in the Problems panel and inline in the editor as you type.

Managing Include Paths and Macros

Configuring Preprocessor Settings

To manage include paths and macros (especially for C/C++ projects):

  • Use the c_cpp_properties.json file inside the .vscode folder.

  • Open Command Palette ( Ctrl+Shift+P / Cmd+Shift+P ), run C/C++: Edit Configurations (UI) to add include paths and define macros.

  • This configuration helps IntelliSense locate headers and apply conditional compilation correctly.

Handling Cross-File References

VS Code supports cross-file references through language extensions:

  • Use Find All References ( Shift+F12 ) to see symbol usage across files.

  • Use Go to Definition ( F12 ) to jump to declarations even if they reside in other files.

  • Ensure your project is properly configured (e.g., include paths) so the language server can resolve symbols across files.

Tip

Common Shortcuts in Visual Studio Code

Here are three of the most common shortcuts that can greatly enhance your productivity in Visual Studio Code:

  • Search in File : Use Ctrl + F to open the search bar and find specific strings within the currently open file. This is useful for quickly locating and navigating to specific pieces of code or text.

  • Search String in All Files : Use Ctrl + H to search for a string across all files in your workspace. This is particularly helpful for refactoring code, finding all instances of a variable or function, and making bulk changes.

  • Go to Definition / Declaration : Use Ctrl + Click on a variable, function, or class to quickly navigate to its definition or declaration. This allows you to easily explore and understand the structure of your codebase.

For more information, visit the Visual Studio Code documentation .