I am trying to rename open files in sublime text 2. In version 2.0.1 Build 2217, you could rename by pressing f2 or by opening the command palette by pressing Ctrl + Shift + P and entering rename. However in the latest version of sublime text 2 which is 2.0.2 Build 2221 when you try to do the same thing nothing happens. I have also entered the following command in the users key binding file but again nothing happens.

{ "keys": ["f2"], "command": "rename_path", "args": {"paths": []} }

This happens on both windows & linux. I have tried this on a fresh copy of Sublime Text 2 with no plugins.

  • 3
    Any clue why this functionality was removed? – user2418306 Mar 19 '16 at 9:41

Copy to your User keymap

{ "keys": ["shift+f2"], "command": "rename_file", "args": { "paths": ["$file"] } }

Create directory/file in your Packages folder: "...Packages/RenameFile/rename_file.py"

import sublime
import sublime_plugin
import os
import functools

class RenameFileCommand(sublime_plugin.WindowCommand):
    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().add(sublime.Region(0, len(name)))

    def on_done(self, old, branch, leaf):
        new = os.path.join(branch, leaf)

            os.rename(old, new)

            v = self.window.find_open_file(old)
            if v:
            sublime.status_message("Unable to rename")

    def is_visible(self, paths):
        return len(paths) == 1
|improve this answer|||||
  • That also makes no difference. – Ishan Dec 5 '13 at 7:05
  • Sorry, forgot the plugin. – d_rail Dec 6 '13 at 5:57
  • Great works. However, the keyboard shortcuts does not show up next to File: Rename when you type it in the command palette. Is this feature removed in the latest version of sublime text as it did not require any plugins in the previous versions (2.0.2 Build 2221). – Ishan Dec 6 '13 at 9:11
  • This is not a Sublime Text feature. It is a simple plugin that I found somewhere. I'm not sure what you used before to rename files, but it seems like you uninstalled it or it is broken. – d_rail Jan 4 '14 at 0:03
  • great that worked! – mahatmanich Jun 5 '14 at 7:38

Reference: http://www.sublimetext.com/forum/viewtopic.php?f=2&t=9534

Another simple way to set up a keyboard shortcut for renaming files:

Install SideBar Enhancements, and set up the shortcut in Key Bindings - User:

{ "keys": ["your shortcut combination"], "command": "side_bar_move" }

|improve this answer|||||
  • the reference is just the right kind. No need to install any package or such. – igaurav Feb 19 '15 at 6:50

Here is a package for Sublime Text 3:


|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.