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

Better​Switch​Header​Implementation

by rwols ST2/ST3

More exhaustive Switch File functionality for the C-family

Details

Installs

  • Total 199
  • Win 99
  • OS X 45
  • Linux 55
Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6
Windows 0 0 0 2 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 2 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0 1 2 2 0 0 0 1 1
OS X 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 1 1 1 0 0 0 0 0 0 0
Linux 0 0 0 0 1 0 0 0 0 0 0 0 1 0 7 3 1 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1

Readme

Source
raw.​githubusercontent.​com

BetterSwitchHeaderImplementation

A simple plugin that “takes over” the menu item in Goto -> Switch File -> Switch Header/Implementation. Actually, it takes over the command that gets invoked by that menu item.

Usage

Just use Switch Header/Implementation like you normally would. That is, either from the menu item in Goto -> Switch File -> Switch Header/Implementation, or by its keybinding, whatever that may be.

For example, if your header file lives in

$project_path/include/awesome/foo.hpp

and your implementation file lives in

$project_path/lib/foo.cpp

then this plugin will actually do the switch.

Two Modes of Operation

When you're in folder mode (you have not opened a .sublime-project file), then the plugin will traverse parent directories. A sanity limit of going up three parent directories is in place. You can change this number in the settings of the plugin, but do not make this number too high, or Sublime might freeze.

If your code base looks like this:

$project_path/include/foo/bar.hpp
$project_path/include/foo/baz/bar.hpp
$project_path/src/bar.cpp

then switching from src/bar.cpp, you'll most likely end up in include/foo/bar.hpp, as that's the first good match. This is the downside of folder mode.

When you're in project mode (you have opened a .sublime-project file), then the plugin will assume that the project file is at the root of the directory, and the search will start there. All candidate files are collected, and if there's more than one candidate file, a quick panel will pop up asking you to select the correct file. From that point on the plugin will always choose your selection for switching. This mode is much more powerful. Use the power of the sublime project file.

Limitations

The plugin might come up with false positives. For example, if your code base looks like this:

$project_path/include/awesome/foo.hpp
$project_path/include/awesome/bar/foo.hpp
$project_path/src/bar/foo.cpp

then switching from include/awesome/foo.hpp, it will open src/bar/foo.cpp. But src/bar/foo.cpp is probably paired with include/awesome/bar/foo.hpp.