Arunprasad Rajkumar 5 years ago • updated by Alexis Sa 4 years ago 5

It would be nice if we were able to get the full path of viewing file. Suppose if user right clicking on the file-tab it should show option to copy the current viewing file's path to clipboard :)


import sublime, sublime_plugin, os

class PathToClipboardCommand(sublime_plugin.TextCommand):

    def run(self, edit):


class FilenameToClipboardCommand(sublime_plugin.TextCommand):

    def run(self, edit):


class FiledirToClipboardCommand(sublime_plugin.TextCommand):

    def run(self, edit):

        branch, leaf = os.path.split(self.view.file_name())


Hi, it is a plugin right? Great work. Thanks for that :D

BTW, do I need to map this to certain key combination? how to make this as usable one? Please help me

Find the class - strip off the "Command" - then convert the CamelCase by separating the words with underscores where you see capital letters. Like following:

Add the following to Key bindings - User:

{ "keys": ["ctrl+alt+c"], "command": "filename_to_clipboard" },

Or to add the commands to the right-click menu, you can create a file named Context.sublime-menu in your User folder containing the following:


    { "command": "filename_to_clipboard", "caption": "Filename to Clipboard" },

    { "command": "filedir_to_clipboard", "caption": "Filedir to Clipboard" },



It is build into core ST.

Right click on the body of the open file (not the tab the bit with the text in it).

There is what you want right there on the menu and it has been there for years.

No need for all the argby bargy in this thread - it is already supplied

Long Path Tool deals with long path files. It works well to
copy or delete long path files.