ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Related Files

by fabiokr ALL

A Sublime Text 2/3 plugin to list related files

Details

  • 2014.10.30.15.27.39
    1.0.1
  • github.​com
  • github.​com
  • 10 years ago
  • 1 hour ago
  • 12 years ago

Installs

  • Total 2K
  • Win 742
  • Mac 1K
  • Linux 458
Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10
Windows 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Sublime Text 3 - Related Files Plugin

Screenshot

This plugin provides a quick list of related files to the currently open file.

My main use case is to list related files under a Ruby on Rails project. For example, for an opened “app/controllers/examples_controller.rb”, related files would be “app/helpers/examples_helper.rb”, “app/views/examples/**”, and “spec/controllers/examples_controller_spec.rb”.

This plugin was inspired by the existing Open Related and Rails Related Files.

I wanted something between the two of them (a quick list of results that could be setup for any kinds of projects, not only Rails), so I created my own.

Key Shortcut

The default shortcut is mapped to “ctrl+super+p”. To change it to something more suitable for your needs, you can easily change that by copying the following and replacing the “keys” to your desired key combination:

{ "keys": ["ctrl+super+p"], "command": "related_files"}

Configuration

The plugins comes configured to lookup Rails related files, but you can add your own setups. Let's see an existing example:

// Test/specs for ruby files
".+\/(app|lib)\/(.+).rb":
  [
    "spec/$2_spec.rb",
    "test/$2_test.rb"
  ]

The configuration has two parts: the key, which is a regular expression to match against the currently open file, and a list of globs to map the related files.

You can use the $1, $2, etc. on the glob strings to be replace by the extracted parts from the regex.

In addition to global configs, you can also have per project configs. To add that, in a sublime project file (project-name.sublime-project), add this:

{
  "settings":
  {
    "RelatedFiles": {
      "patterns": {
        // you project patterns
      }
    }
  }
}