将 Eclipse 中的路径/文件名复制到剪贴板
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8006250/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Copy path/file name in Eclipse to clipboard
提问by user710818
Is there a shortcut to copy the current path/file to the clipboard?
是否有将当前路径/文件复制到剪贴板的快捷方式?
采纳答案by Rangi Lin
There is Copy Qualified Name
function in Eclipse, it will copy the full name of the element you select (or element on cursor).
Copy Qualified Name
Eclipse 中有一个功能,它会复制您选择的元素(或光标上的元素)的全名。
For example :
例如 :
/MyProject/src/app/Application.java
: when you select Application.java in Package Explorer
/MyProject/src/app/Application.java
: 当你在 Application.java 中选择 Package Explorer
java.util.HashSet<String>
: when you copy while cursor at HashSet<String>
java.util.HashSet<String>
: 当你在光标处复制时 HashSet<String>
However, it required you to selectthe element you want.
但是,它要求您选择所需的元素。
So, here is what I do.
所以,这就是我所做的。
Make your
Package Explorer
link with editor, you can active this by click the double-arrow icon at top-right corner.Set up a hot-key for
Show View (Package Explorer)
ex : Alt+ 1Set up a hot-key for
Copy Qualified Name
ex : Alt+ Ctrl+ Shift+ c
Package Explorer
与编辑器建立链接,您可以通过单击右上角的双箭头图标来激活它。为
Show View (Package Explorer)
ex设置热键:Alt+1为
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 F12back to your editor, or simply ESCif you use fast view.
每当我需要当前文件中的这些信息时,我只需按热键即可调用我的Package Explorer
因为它与编辑器链接并且将始终选择当前编辑器中的文件,您只需使用热键复制即可。然后您可以使用F12返回到您的编辑器,或者只是ESC使用快速视图。
Not perfect, but it works :D
不完美,但它有效:D
回答by Peter Szanto
- Just select the file tab and hit Ctrl+Cto copy file basenameinto clipboard.
- Hit Alt+Enterto bring up the file properties with absolute pathand 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/
- 只需选择文件选项卡并点击Ctrl+C将文件基本名称复制到剪贴板。
- 点击Alt+Enter以使用绝对路径调出文件属性并手动复制它。
- 此外,您可以使用可以一次性完成这些步骤的 Eclipse 宏插件:http: //sourceforge.net/projects/practicalmacro/files/
回答by ThomasW
There is yet another plugin that supports copying the path along with a number of other related functions:
还有另一个插件支持复制路径以及许多其他相关功能:
http://code.google.com/p/pathtools/
http://code.google.com/p/pathtools/
Just search Eclipse Marketplace within Eclipse for 'pathtools'.
只需在 Eclipse 中的 Eclipse Marketplace 中搜索“pathtools”。
回答by Tod
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.
您可以通过配置一个 Eclipse 外部工具(我认为这是一个未被充分利用的工具),通过一次按键操作来完成。第一次使用它需要大约一分钟的时间来配置,但它总是可用的。这是一个演示该技术的 YouTube视频。
回答by krm
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.
Rangi Lin 答案的替代方案,它提供了一些附加功能:Eclipse 的 StartExplorer 插件。Rangi Lin 提到的解决方案并非在所有情况下都有效。它在我的情况下不起作用,例如在同步视图中的团队同步透视图中。但是,StartExplorer 的上下文菜单命令“将资源路径复制到剪贴板”以及它的默认键盘快捷键 (Ctrl+Alt+C) 也可以在那里使用。此插件的优点是它还允许您在所选文件等位置打开文件管理器。
回答by Mark
Alt+Enter- open properties
Alt+ Enter- 打开属性
Alt+L- go to path location
Alt+ L- 转到路径位置
Shift+End- select path
Shift+ End- 选择路径
Ctrl+C- copy
Ctrl+ C- 复制
回答by Legolas
回答by Irshad N
- Go to Project Explorer View in Eclipse which is at the left panel.
- Click on link with editor.
- After linking, your opened file will get selected.
- Right-click on the selected file. You will get the option 'Copy Qualified Name' which is just below 'Copy' option.
- 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.
- In the folders address bar, the address will be like this:
D:\project
. - Paste in front of this address like:
D:\project/abc/source/com/connect.java
- Delete the java file name(connect.java) and press
enter
.
- 转到位于左侧面板的 Eclipse 中的 Project Explorer View。
- 单击与编辑器的链接。
- 链接后,您打开的文件将被选中。
- 右键单击所选文件。您将获得“复制限定名称”选项,该选项位于“复制”选项下方。
- 打开项目所在的目录。例如,如果您的项目是“abc”并且它位于“project”目录中,请转到“project”目录。
- 在文件夹地址栏中,地址将是这样的:
D:\project
。 - 粘贴在这个地址前面,如:
D:\project/abc/source/com/connect.java
- 删除 java 文件名(connect.java)并按
enter
。
You will be in folder 'com'.
您将位于“com”文件夹中。
回答by Aman
回答by Andrzej
The video demonstrating the techniquewas prepared for Eclipse in Windows. In Linux you have to change:
演示该技术的视频是为 Windows 中的 Eclipse 准备的。在 Linux 中,您必须更改:
- External Tools Configurations - Location: /home/username/path/to/script.sh
- External Tools Configurations - Arguments: ${selected_resource_loc}
- External Tools Configurations - Standard Input and Output - CHECK"Allocate console (necessary for input)"
- Create a script /home/username/path/to/script.sh as follows
- 外部工具配置 - 位置:/home/username/path/to/script.sh
- 外部工具配置 - 参数:${selected_resource_loc}
- 外部工具配置 - 标准输入和输出 -检查“分配控制台(输入所需)”
- 创建脚本 /home/username/path/to/script.sh 如下
echo $1
echo $1 > /home/username/clipboard_tmp.txt
xclip -in -selection clipboard /home/username/clipboard_tmp.txt
xclip -selection clipboard -o
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)
我不知道为什么,但是以下命令echo $1 | xsel --clipboard
在脚本中不起作用。它已在 Ubuntu 12.04 LTS 和 Eclipse IDE 中为 C/C++ 开发人员检查(版本:Kepler Service Release 2,构建 ID:20140224-0627)