Editing ¶
Note
All editor features are disabled until you select a CMake preset.
Explorer and file management ¶
The Explorer view in Visual Studio Code (VS Code) provides an overview and navigation of your project’s files and folders. The following list summarizes its key functionalities:
File navigation: Browse, open, and manage files and directories in your workspace. Quickly locate and access any file within your project.
File operations: Create, delete, rename, and move files and folders directly within the Explorer view.
Search integration: Search for files and content within your project. Viewed and access search results directly from the Explorer.
Version control: View version control status for files such as those managed by Git. See which files are modified, added, or deleted, and access version control commands from the Explorer.
Drag and drop: Move or copy files and folder within the project structure using drag-and-drop functionality.
Context menu: Access additional options and commands by right-clicking files or folders. The menu includes file operations and version control options.
File preview: Preview files without opening them in a new tab. Clicking a file in the Explorer displays a preview in the editor area.
Workspace management: Add or remove folders from your workspace and switch between workspaces.
The Explorer view in VS Code is a tool for managing and navigating your project’s file structure, improving productivity in your development workflow.
Code editor features ¶
Syntax highlighting and code completion ¶
Syntax highlighting is enabled in Visual Studio Code based on the file extension and installed language extensions. To use code completion (IntelliSense) :
Start typing code to display suggestions automatically.
Trigger suggestions manually with Ctrl+Space (Windows/Linux) or Cmd+Space (macOS).
Use arrow keys to navigate suggestions and press Enter or Tab to accept.
Advanced editing tools ¶
Code snippets and templates ¶
To insert code snippets:
Start typing the snippet prefix, then select the snippet from IntelliSense suggestions.
Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (macOS), type Insert Snippet, and select the desired snippet.
Customize or add snippets by editing the snippets files through Preferences: Configure User Snippets.
Integration with static code analysis ¶
Static analysis tools, such as ESLint, Pylint, or Cppcheck, can be integrated using extensions.
Install the relevant extension from the VS Code Marketplace.
Configure tool settings in .vscode/settings.json or project configuration files.
Issues and warnings appear in the Problems panel and inline in the editor.
Managing include paths and macros ¶
Configuring preprocessor settings ¶
To manage include paths and macros for C/C++ projects:
Use the c_cpp_properties.json file in 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 enables IntelliSense to locate headers and apply conditional compilation.
Handling cross-file references ¶
VS Code supports cross-file references through language extensions:
Use Find All References (Shift+F12) toview symbol usage across files.
Use Go to Definition (F12) to jump to declarations in other files.
Ensure your project is configured correctly, such as include paths, so the language server can resolve symbols across files.
Tip
Common shortcuts in Visual Studio Code
The following shortcuts enhance productivity in Visual Studio Code:
Search in file: Press
Ctrl + Fto open the search bar and find strings within the current file. This is useful for quickly locating and navigating to specific pieces of code or text.Search string in all files: Press
Ctrl + Hto search for a string across all files in the workspace. This is particularly helpful for refactoring code, finding all instances of a variable or function, and making bulk changes.Go to definition or declaration: Press
Ctrl + Clickon a variable, function, or class to navigate to its definition or declaration. This allows you to easily explore and understand the structure of your codebase.
For more information, see Visual Studio Code documentation.