Giter Club home page Giter Club logo

vscode-file-ext-switcher's Introduction

file-ext-switcher

Once set up file-ext-switcher allows you to quickly switch via keyboard shortcuts between files which share same name but differ by extension (AKA companion files, e.g. from file.html to file.js). This is very useful for Angular (and even AngularJs) component development where you need to quickly switch between code, template, style and test files.

This extension provides key-bindable VS code commands for every supported file type that you specify. Please note that you must set up bindings first, see Setup.

Features

Switch to/between any companion file(s) in the same directory that shares at least one file-name component. Examples of usage:

  • Switch to styles .css or .scss
  • Open .html template in another editor column in split mode
  • Switch between .ts and generated .js files
  • Switch from .ts to .spec.ts and back

Setup

Bind your custom keybindings to the fileextswitch commands for super-fast switching.

  1. In VSCode open Command Palette
  2. Type in and select Preferences: Open Keyboard Shortcuts File
  3. Add one or more custom file-ext-switcher keybinding into the file

A sample keybinding looks like this:

{
    "key": "ctrl+shift+j",
    "command": "fileextswitch",
    "args": { 
        "extensions": [".html", ".ts",], // extensions to switch to (in the exact order)
        "useOtherColumn": true // open companion file in other editor column (default false)
    }, 
    "when": "editorTextFocus"
},

Example Keybindings

Open companion file in other column

These shortcuts open a companion file in the other editor column (note the useOtherColumn: true), so you can quickly open your component.ts definition next to your component.html:

{
    "key": "ctrl+shift+j",
    "command": "fileextswitch",
    "args": { "extensions": [".html"], "useOtherColumn": true }, 
    "when": "editorTextFocus"
},
{
    "key": "ctrl+shift+k",
    "command": "fileextswitch",
    "args": { "extensions": [".js", ".ts"], "useOtherColumn": true }, 
    "when": "editorTextFocus"
},
{
    "key": "ctrl+shift+l",
    "command": "fileextswitch",
    "args": { "extensions": [".css", ".scss"], "useOtherColumn": true }, 
    "when": "editorTextFocus"
},
{
    "key": "ctrl+shift+;",
    "command": "fileextswitch",
    "args": { "extensions": [".spec.ts"], "useOtherColumn": true }, 
    "when": "editorTextFocus"
}

Cycle through companion files

When invoked, the command will look for files in the same directory of the current file, which share at least one base component (e.g. "app" for a file named "app.module.ts"). Matching follows the order of specified extensions, locating the current file's extension in the list and then cycling through to the next file extension. This allows e.g. to generate a keyboard shortcut for cyclic switching between file extensions:

{
        "key": "ctrl+shift+i",
        "command": "fileextswitch",
        "args": {
            "extensions": [
                ".ts",
                ".html",
                ".scss"
            ]
        },
        "when": "editorTextFocus"
    }

Contributing

Please report issues and submit pull-requests to https://github.com/JohannesRudolph/vscode-file-ext-switcher

Acknowledgements

If you prefer a graphical companion file switcher and can live without keybindings, check out the excellent companion-file-switcher extension.

vscode-file-ext-switcher's People

Contributors

duncanbeevers avatar johannesrudolph avatar norvegec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vscode-file-ext-switcher's Issues

Ignore Name Option - force file extension

Hi,
i would like to use this extension but its not working with our coding guidlines. We have different names for the files but seperated by folders.

I would love to see an option for this kind of use:

/User-----/
/-----------/user.component.ts
/-----------/user.template.html
/-----------/user.scss
/-----------/user.service.spec.ts

Any way to toggle between two extensions?

Great extension by the way! Was wondering if it is able to support pressing F12 once to go from a .TS file to an .HTML file, and then pressing F12 again to go from the .HTML file back to the .TS file.

clarify how to apply settings

some of the language in the readme makes it seem like the "Features" section are just preferences to be set. In this extension they are all defined in the keybindings.json file. I think bringing that information up higher before the "Features" section would be more clear.

also creating this issue for awareness for other people who run into this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.