45

How to set shortcut for Copy file path in sublime text 3? I tried:

[
    { "keys": ["super+i"], "command": "copy_file_path" }
]   

But seemingly command copy_file_path not valid.

shortcut for "Copy file path" in sublime text 3

Maxim Yefremov
  • 1,245
  • 5
  • 16
  • 21

2 Answers2

72

All you need to do is change "copy_file_path" to "copy_path".


To discover this, I hit Ctrl` to open the console, then ran

sublime.log_commands(True) 

to have all actions logged to the console. I then right-clicked and selected Copy File Path, and

command: copy_path 

showed up. I assigned the key combination, ran it, and it worked. To finish up, I run

sublime.log_commands(False) 

so the console doesn't get clogged with unnecessary info, then hit Ctrl` again to close the console.

MattDMo
  • 5,309
  • 24
  • 30
  • I would really appreciated if you could say how you came to know about `sublime.log_commands`? Probably sublime's API? – hamid Dec 14 '14 at 11:20
  • 1
    @Hamid yes, this is documented in Sublime's [API](http://www.sublimetext.com/docs/3/api_reference.html). – MattDMo Dec 14 '14 at 18:16
  • Great answer. thanks @MattDMo. Do I need to install a package for this? I tried right clicking on a file in the sidebar in ST3, and it does not give that as an option. "Copy File Path" is not there. Any ideas? – cavalcade Mar 08 '15 at 05:22
  • @MattTagg this doesn't work when clicking in the sidebar, you have to click in the body of the file. For working with files in the sidebar, I highly recommend installing the [SideBarEnhancements](https://packagecontrol.io/packages/SideBarEnhancements) plugin via Package Control. – MattDMo Mar 08 '15 at 05:29
  • @MattDMo ahh got it now. Thanks for the help – cavalcade Mar 08 '15 at 09:31
  • How do you know that `copy_path` is the right command ? How do we know what available ? Is there any docs that I miss ? – code-8 Feb 18 '17 at 04:56
1

For those like me that need a shortcut to copy the relative path,

{ "keys": ["alt+p"], "command": "copy_relative_path" }