Path Converter VSCode Extension
A VSCode extension that converts relative paths to absolute paths using Path Intellisense mappings.
Features
- Convert relative paths (e.g.,
~/foo/bar.js) to absolute paths (e.g., /share/org/YZWL/yzwl_wenhao/foo/bar.js)
- Uses
path-intellisense.mappings configuration from VSCode settings
- Keyboard shortcut:
Ctrl+Shift+Alt+P (Windows/Linux) or Cmd+Shift+Alt+P (Mac)
- Supports multiple path prefixes defined in the mappings
- Automatically detects the path at cursor position
Installation
- Clone this repository
- Run
npm install to install dependencies
- Run
npm run compile to build the extension
- Press
F5 in VSCode to open a new Extension Development Host window
- Test the extension in the new window
Configuration
Add path mappings to your VSCode settings (.vscode/settings.json or user settings):
{
"path-intellisense.mappings": {
"~": "/share/org/YZWL/yzwl_wenhao",
"@": "/project/src",
"$lib": "/usr/local/lib"
}
}
Usage
- Place your cursor on a relative path (e.g.,
~/foo/bar.js)
- Press
Ctrl+Shift+Alt+P (or Cmd+Shift+Alt+P on Mac)
- The path will be converted to its absolute form based on your mappings
Example
Before:
import { foo } from '~/utils/helper.js';
After (with mapping "~": "/share/org/YZWL/yzwl_wenhao"):
import { foo } from '/share/org/YZWL/yzwl_wenhao/utils/helper.js';
Commands
Convert Relative Path to Absolute: Convert the path at cursor position to absolute path
Development
Building
npm install
npm run compile
Watching for Changes
npm run watch
Linting
npm run lint
Requirements
- VSCode 1.75.0 or higher
- Node.js and npm
Known Issues
None at this time.
Publishing
To publish this extension to the VSCode Marketplace:
Prerequisites
- Create a publisher account at Visual Studio Marketplace
- Install
vsce (Visual Studio Code Extensions):
npm install -g @vscode/vsce
- Get a Personal Access Token (PAT) from Azure DevOps
Steps to Publish
Update the publisher name in package.json:
"publisher": "your-publisher-name"
Package the extension:
vsce package
This creates a .vsix file.
Test the package locally:
- In VSCode, go to Extensions view
- Click "..." menu → "Install from VSIX..."
- Select the
.vsix file
Publish to marketplace:
vsce publish
Or manually upload the .vsix file to the marketplace.
Pre-publish Checklist
- [x] All tests pass (
npm test)
- [x] Code compiles without errors (
npm run compile)
- [x] Extension tested in development mode (F5)
- [x] README.md is complete and accurate
- [x] LICENSE file exists
- [x] CHANGELOG.md is up to date
- [x] package.json has all required fields (publisher, repository, etc.)
- [ ] Publisher name is set to your actual publisher ID
- [ ] Version number is appropriate
Release Notes
See CHANGELOG.md for detailed release notes.
0.0.1
Initial release:
- Basic path conversion functionality
- Support for multiple path prefixes
- Keyboard shortcut support
| |