Copy path/file name in Eclipse to clipboard

时间秒杀一切 提交于 2019-12-03 08:12:34

问题


Is there a shortcut to copy the current path/file to the clipboard?


回答1:


There is Copy Qualified Name function in Eclipse, it will copy the full name of the element you select (or element on cursor).

For example :

/MyProject/src/app/Application.java : when you select Application.java in Package Explorer

java.util.HashSet<String> : when you copy while cursor at HashSet<String>

However, it required you to select the element you want.

So, here is what I do.

  1. Make your Package Explorer link with editor, you can active this by click the double-arrow icon at top-right corner.

  2. Set up a hot-key for Show View (Package Explorer) ex : Alt + 1

  3. Set up a hot-key for Copy Qualified Name ex : Alt + Ctrl + Shift + c

Whenever I need these information in current file, I just press the hot-key to call my Package Explorer Since it links with editor and will always select the file in current editor, you can just copy with the hot-key. Then you can use F12 back to your editor, or simply ESC if you use fast view.

Not perfect, but it works :D




回答2:


  • Just select the file tab and hit Ctrl+C to copy file basename into clipboard.
  • Hit Alt+Enter to bring up the file properties with absolute path and copy it manually.
  • Additionally you can use an Eclipse macro plugin that can do the steps in one go: http://sourceforge.net/projects/practicalmacro/files/



回答3:


There is yet another plugin that supports copying the path along with a number of other related functions:

http://code.google.com/p/pathtools/

Just search Eclipse Marketplace within Eclipse for 'pathtools'.




回答4:


You can do it with a single keystroke by configuring an Eclipse external tool (a much underused tool in my opinion). Takes about a minute to configure the first time you use it but then it's always available. Here's a YouTube video demonstrating the technique.




回答5:


An alternative to the answer of Rangi Lin, which provides some additional functionality: The StartExplorer plugin for Eclipse. The solution mentioned by Rangi Lin doesn't work in all cases. It doesn't work in my case e.g. in the Team Synchronizing perspective in the Synchronize view. However, the StartExplorer's context menu command "Copy Resource Path To Clipboard", as well as the default keyboard shortcut for it (Ctrl+Alt+C) works also there. The advantage of this plugin is that it additionally allows you to open the file manager at the location of the selected file etc.




回答6:


Another option is EasyShell. It has a single entry in the context menu, under which you'll find copying of the path, opening explorer, a dos box and others (configurable).




回答7:


Alt+Enter - open properties

Alt+L - go to path location

Shift+End - select path

Ctrl+C - copy




回答8:


  1. Go to Project Explorer View in Eclipse which is at the left panel.
  2. Click on link with editor.
  3. After linking, your opened file will get selected.
  4. Right-click on the selected file. You will get the option 'Copy Qualified Name' which is just below 'Copy' option.
  5. Open the directory where your project resides. e.g. if your project is 'abc' and it's in the directory 'project', go to the 'project' directory.
  6. In the folders address bar, the address will be like this: D:\project.
  7. Paste in front of this address like: D:\project/abc/source/com/connect.java
  8. Delete the java file name(connect.java) and press enter.

You will be in folder 'com'.




回答9:


The video demonstrating the technique was prepared for Eclipse in Windows. In Linux you have to change:

  1. External Tools Configurations - Location: /home/username/path/to/script.sh
  2. External Tools Configurations - Arguments: ${selected_resource_loc}
  3. External Tools Configurations - Standard Input and Output - CHECK "Allocate console (necessary for input)"
  4. Create a script /home/username/path/to/script.sh as follows

echo $1 echo $1 > /home/username/clipboard_tmp.txt xclip -in -selection clipboard /home/username/clipboard_tmp.txt xclip -selection clipboard -o

I don't know why, but following command echo $1 | xsel --clipboard doesn't work in the script. It was checked in Ubuntu 12.04 LTS and Eclipse IDE for C/C++ Developers (Version: Kepler Service Release 2, Build id: 20140224-0627)



来源:https://stackoverflow.com/questions/8006250/copy-path-file-name-in-eclipse-to-clipboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!