13

How do you copy the file name of the currently opened file in sublime text 3 ? If this is not possible by default, perhaps you know some sublime extension which does that job using keyboard shortcut.

3
  • 3
    You can right-click within the file and select "Copy File Path", would that do?
    – MattDMo
    Nov 1, 2015 at 1:02
  • @MattDMo Please add that as an answer. I did not see your comment. This is the only answer that works currenly.
    – Sohail Si
    Jul 9, 2021 at 10:31
  • 1
    @SohailSi all set
    – MattDMo
    Jul 9, 2021 at 14:50

3 Answers 3

20

You can do this if you have the SideBarEnhancements plugin installed.

  1. Open up the command palette with Ctrl+Shift+P (on Mac it is +Shift+P)

  2. Type File: Copy Name and press Enter

The file name has now been copied to your clipboard.


Setting a hotkey for this command:

  1. Go to your Key Bindings -> User file

  2. Add this line to your file: { "keys": ["ctrl+shift+l"], "command": "side_bar_copy_name" }

  3. Change "ctrl+shift+l" to whatever command you want to use.

4
  • This function is now called File: Copy Absolute Path.
    – MS Berends
    Feb 11, 2020 at 14:54
  • This just copied the name of the file. What if I want to copy the full PATH? Mar 19, 2020 at 2:47
  • It didn't work for me. No file: Copy. (even using absolute). Youo probably have a plugin that enables that. (as of 9 July 2021, build 4107)
    – Sohail Si
    Jul 9, 2021 at 10:29
  • 2
    Yeah, the first line of this answer mentions you can do it if you have the SideBarEnhancements plugin installed
    – Saad
    Jul 9, 2021 at 23:24
1

In Sublime Text 3 and 4, you can simply right-click within the file body itself and select Copy File Path.

Using the SideBarEnhancements plugin is also an option when you're browsing through files contained within folders that you have added to your project (that show on the lower part of the sidebar). There, just right-click on the file and select Copy Path or Copy Dir Path.

0

You can download CopyFileName to do just that.

To install it, extract the .zip file to your Packages folder, wich you can access via:

Preferences --> Browse packages

To actually use it:

Open or preview the file --> Right click somewhere in it (not on the tab) --> Copy File Name

1
  • This functionality is currently built in to ST, you don't need a plugin.
    – MattDMo
    Jul 9, 2021 at 14:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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