YAML Line Finder
A VSCode extension that helps you quickly find and jump to YAML keys in your files and translation files.
Features
- Find YAML key in current file: Open a prompt to search for a YAML key and jump to the line where it's defined
- Jump to translation file: Jump from a string in your code to the corresponding key in a configured translation file
Commands
YAML Line Finder: find in current file
- Command ID:
yamlLineFinder.findKeyInCurrentFile
- Opens an input prompt asking for a YAML key path (using dot notation, e.g.,
server.database.user )
- Jumps to the line where the key is defined in the current file
YAML Line Finder: jump to translation file
- Command ID:
yamlLineFinder.jumpToTranslationFile
- Uses the word under the cursor as the YAML key
- Jumps to that key in the configured translation file for the current file type
- Requires
translationFiles configuration
Configuration
yamlLineFinder.translationFiles
An array of translation files. Each entry specifies a translation file and the languages/file types it applies to.
Type: array
Default: []
Scope: Resource
Example configuration in .vscode/settings.json :
{
"yamlLineFinder.translationFiles": [
{
"languages": ["erb", "ruby"],
"path": "config/locales/en.yml",
"keyPrefix": "en",
"relativeTo": "app/views"
},
{
"languages": ["javascript", "typescript"],
"path": "src/locales/en.yaml"
}
]
}
Configuration properties:
- languages (array, required): An array of language/file type identifiers this translation file applies to
- path (string, required): The file path to the translation YAML file
- keyPrefix (string, optional): A prefix to prepend to the key when looking up values
- relativeTo (string, optional): A relative path used for resolving lazy lookup keys (useful for Rails-style translation keys starting with a dot)
In this example:
- When you're editing an ERB file, it will look for keys in
config/locales/en.yml with the prefix en and resolve relative paths from app/views
- When you're editing JavaScript or TypeScript files, it will look in
src/locales/en.yaml
Usage Example
Finding a key in the current file
- Open a YAML file (or any text file containing YAML)
- Run the command "YAML Line Finder: find in current file"
- Type the key path you're looking for (e.g.,
users.admin.name )
- The editor will jump to the line where that key is defined
Jumping to a translation file
- Open a file that's configured to use a translation file
- Place your cursor on a word (the translation key)
- Run the command "YAML Line Finder: jump to translation file"
- The editor will open the translation file and jump to the line where the key is defined
Requirements
- VSCode 1.90.0 or higher
- Node.js (for development)
Development
Installation
npm install
Building
npm run compile
Development mode with watch
npm run watch
License
MIT
| |