Here is the solution:
1. Open "Preferences/Key Bindings User"
2. Add this binding to you list of personal bindings:
- Code: Select all
{ "keys": ["shift+f6"], "command": "rename_path", "args": {"paths": ["$file"]} }
So my overall custom binding map looks like this:
- Code: Select all
[
{ "keys": ["alt+f1"], "command": "reveal_in_side_bar" },
{ "keys": ["alt+f2"], "command": "open_dir", "args": {"dir": "$file_path", "file": "$file_name"} },
{ "keys": ["ctrl+alt+s"], "command": "save_all" },
{ "keys": ["ctrl+alt+h"], "command": "htmlprettify" },
{ "keys": ["ctrl+keypad0"], "command": "focus_side_bar" },
{ "keys": ["shift+f6"], "command": "rename_path", "args": {"paths": ["$file"]} }
]
3. When pressing shift+f6 on the current file should result in a new edit window with the literal "$file"
4. Now to have sublime check for the current file being edited I needed to update my side_bar.py file. This file is where the rename file command lives and is the same command used when you rename a file from the side bar right click menu.
5. Add this line of code to the RenamePathCommand Class under the run function.
- Code: Select all
if paths[0] == "$file":
paths[0] = self.window.active_view().file_name()
So my whole run function now looks like this:
- Code: Select all
def run(self, paths):
if paths[0] == "$file":
paths[0] = self.window.active_view().file_name()
branch, leaf = os.path.split(paths[0])
v = self.window.show_input_panel("New Name:", leaf, functools.partial(self.on_done, paths[0], branch), None, None)
name, ext = os.path.splitext(leaf)
v.sel().clear()
v.sel().add(sublime.Region(0, len(name)))
Now once everything is saved try to rename a file again and you should get the actual file name instead of "$file". When the rename occurs it will update the current view to the new file name.
I hope this helps you guys out!