You can use a plugin to do what you want
import os
import sublime
import sublime_plugin
class OpenCfileCommand(sublime_plugin.TextCommand):
def run(self, edit):
base_path = os.path.split(self.view.file_name())[0]
for file in os.listdir(base_path):
if file.endswith(".c"):
c_file_path = os.path.join(base_path, file)
else:
self.view.window().status_message("No c file found")
self.view.window().open_file(c_file_path, flags=sublime.FORCE_GROUP)
and have a keybinding to it (keybinding is upto you)
{
"keys": ["ctrl+alt+4"],
"command": "open_cfile",
}
So if you now press ctrl+alt+4 when you have one of your .cpp
or .hpp
files open, it should open the corresponding .c
file located in the same directory (provided thats the only .c
file you have otherwise it will open the .c
file(s) last in the alphabetical order).
Hopefully this helps.