Preprocessor Section Select
A VS Code extension that provides Source Insight-like functionality for selecting and navigating preprocessor sections (#ifdef/#if/#else/#endif).
Features
- Triple-Click Selection: triple-click on any preprocessor directive to select the entire block (enabled by default, configurable)
- Select Preprocessor Section: select the entire preprocessor block
- Go to Matching Preprocessor: jump between matching preprocessor directives
Supported Directives
#if
#ifdef
#ifndef
#elif
#else
#endif
#if defined(...)
Supported Languages
- C
- C++
- Objective-C
- Objective-C++
Keybindings
| Action |
Keybinding |
| Select Section |
NA (manual setting) |
| Go to Match |
NA (manual setting) |
Installation
From VSIX File
- Download the
.vsix file from Releases
- Run:
code --install-extension preproc-select-*.vsix
From Source
# Clone the repository
git clone https://github.com/allen840707/vscode-preproc-select.git
cd vscode-preproc-select
# Install dependencies
npm install
# Compile TypeScript
npm run compile
# Package the extension
npm run package
Then install the generated .vsix file.
Publish to Marketplace
# Install vsce if not already installed
npm install -g vsce
# Package and publish
npm run package
npm run publish
Usage
Select Preprocessor Section
- Place cursor on a preprocessor line (
#if, #ifdef, #else, #endif, etc.)
- execute command - Select Preprocessor Section
- The entire preprocessor block will be selected
Navigate Between Directives
- Place cursor on any preprocessor directive
- Execute command - Go to Matching Preprocessor
- Jump to the matching directive:
- From
#if → first #else/#elif or #endif
- From
#else → #endif
- From
#endif → corresponding #if
Testing
Run the included test script to verify correctness:
npm test
Configuration
The extension automatically activates for C/C++ files.
Triple-Click Feature
The triple-click feature is enabled by default. To disable it, add the following to your VS Code settings (settings.json):
{
"preproc-select.enableTripleClick": false
}
License
MIT
| |