Is there a shortcut to copy the current path/file to the clipboard?
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/
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.
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 + 1
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
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'.
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.
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.
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).
Alt+Enter - open properties
Alt+L - go to path location
Shift+End - select path
Ctrl+C - copy
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.
You will be in folder 'com'.
The video demonstrating the technique was prepared for Eclipse in Windows. In Linux you have to change:
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
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)
In Eclipse Version: 2020-03 (4.15.0)
In Project Explorer
Select your file> right Click> Copy Qualified Name
Related
I have found that using the Eclipse "external tools" launch configuration is the best way to open my favorite editor on the current file in Eclipse, notably offering a one-time and super-flexible configuration versus the "Open With" menu, which I had tried to use beforehand and always found wanting, constraining, limiting, and requiring repetitive work for many file types. I set up this external tool as follows and this works great for files in my project:
Run:External Tools:External Tools Configurations...
New launch configuration
On the "Build" tab, un-check "Build before Launch"
On the Common tab, check "External Tools" under the "Display in favorites menu"
On the Main tab, enter "/usr/bin/myeditor" for the Location
Under "Working Directory" I am able to leave this blank
Under arguments ${resource_loc}
(At the top, in the "Name" field whatever I want the name to show up as)
I originally found this general technique for launching an external editor right here on stackoverflow.
So you can see ${resource_loc} or ${resource_path} is the one and only variable I need for this to work, and it does work great when I open a file located inside my Eclipse project and click the external tool. That part is fine.
But the problem I have just discovered occurs when I open a file that is not specifically listed in my project and then click the external tool button. It no longer works and I get an error dialog saying: "Variable references empty selection: ${resource_loc}."
Specifically, to reproduce this, I can create a new C++ "Hello World" project (CDT is included in my Eclipse along with Java) then add the line #include "/tmp/whatever.h" at the top of the one cpp file in the project and then right-click on "/tmp/whatever.h" and use the command "Open Declaration" and Eclipse kindly opens the file /tmp/whatever.h. Finally, I invoke my external tool intending to view whatever.h in my editor, and bang, that's when the problem occurs. (Before doing this I put a harmless line of commented text into /tmp/whatever.h.)
Before some SOer asks, no I am not actually trying to #include "/tmp/whatever.h". I am using this #include example as a specific way to show how the error can be reproduced. If you must know, in my case I actually observed the error when trying to open the editor while using Eclipse to browse framework files, files that are not part of my project.
I have already tried ${resource_path} to see if maybe that might have something in it in this context, but same error, and I have looked at the documented list of Eclipse launch variables here and again I don't see anything that looks like it would be more well-defined in the context of a file that is not part of the current project.
My assessment right now is that this is an unsolvable problem and likely just a limitation of trying to use the "External Tools" for this editor launching business. I only settled on that after using the default "Open With" menu in Eclipse for a while and finding the whole setup there highly unsatisfactory and requiring repeated configuration and actually IIRC it just would not work at all I believe in the context of my editor and controlling how many windows are created, whether one or many or one per project etc. Above, I simplified the launch for demonstration purposes.
OS: GNU/Linux Xubuntu 15.10.
Eclipse: Mars.1 Release (4.5.1) Build id: 20150924-1200
You can circumvent the "Workspace is the top-most Eclipse place" rule by linking files (or folders for that matter) in a project.
Example:
Create a new project:
File → New → Project → General → Project → Next → Project name: LinkProject → Finish
Create a file outside-workspace anywhere outside your Eclipse workspace dir.
Import this file as link:
Select LinkProject → File → Import... → General → File System → Next > → From directory: <as chosen for the file above> → Check ☑️ 📄 outside-workspace→ (⚠️ The next can be overlooked easily!) Advanced >> → Check ☑️ Create links in workspace → Finish
NB: I doesn't matter whether you uncheck ☐ Create link locations relative to: PROJECT_LOC ˅ or what you select from the list. ${resource_loc} is always the same. Just the file's/folder's Properties → Location: changes. There is a new property for linked files/folders: Resolved location which shows what ${resource_loc} is resolved to: an FQFN.
And, once you linked a file/folder in your project it is part of your project and you can also access it relatively, e.g. with ${workspace_loc:/LinkProject/outside-workspace}' which resolves to the FQFN, too.
See also Eclipse Platform User Guide – Linked resources.
From Eclipse, how to go to the specific folder? I mean in windows, how to open a command line which corresponding to the folder or direct open the file explorer to open the corresponding folder?
You have to create an external tool with location ${env_var:SystemRoot}\explorer.exe (or cmd.exe) and arguments /select,${resource_loc} . Any selected file or directory can now be shown in the windows explorer.
Create an External tool
Go into the external tool configuration (you can find it into the corresponding toolbar icon) :
Then you can create your own external tool :
Create a new Program (select Program in the tree)
Name it shell
Set the location to ${env_var:SystemRoot}\explorer.exe
Set the arguments to /select,${resource_loc}
Run the external tool
Once created you can run the external tool from the context menu or from the toolbar ...
I have been using an Eclipse plugin called PathTools for sometime now, and am happy with it.
It adds a number of buttons to the Eclipse toolbar which allow you to :
Directly open a cmd prompt at the selected folder.
Open an Explorer window for the selected folder.
Update site : http://pathtools.googlecode.com/svn/trunk/PathToolsUpdateSite/site.xml
Sample screenshots
Installing the `Path Tools Feature`
I chose to install only the Path Tools Feature
Opening a terminal
Opening a terminal directly at the Folder Path :
(The above snapshot is that for OSX but works in Windows as well)
Opening Explorer
Opening a folder directly in Explorer/Finder :
Great simple plugin for this:
http://basti1302.github.com/startexplorer/
2019 update (no plugins required):
Right click the desired folder in the Project Explorer, go to Show In, choose either Terminal or System Explorer. See below screenshot:
Right click the file (in left pane).. then use Win Goodies -> Open file in Explorer
In Visual Studio, or MyEclipse, you have a button which is able to locate a source file on disk, and open the containing directory in Windows explorer.
This is useful, for example, to browse images, or to use an other tool when a conflict occurs in CVS or SVN.
What would be the way to do it in Eclipse with a free plugin, or without any plugin ?
I found it :
"In eclipse, it is common requirement to open the folder containing source file but there is no direct method to do that like in Visual studio of Microsoft."
http://shivasoft.in/blog/others/tips/locate-source-file-on-local-disc-in-eclipse-external-tool/
An actual plugin can be found at http://blog.samsonis.me/2009/02/open-explorer-plugin-for-eclipse/
And version 1.5 can be found here http://blog.samsonis.me/2011/08/openexplorer-eclipse-plugin-1-5-0/
One that I've since upgraded to & find more useful
http://basti1302.github.io/startexplorer/
I always do this:
right click on file/folder, show in..., system explorer. Done.
I guess we don't need a plugin to do that, or I am misunderstanding the question?? I am using Luna 4.4.2 on Windows 7.
On Mac you can follow this steps to add it without a plug-in:
Click the disclosure icon to the right of the External Tools icon:
Select External Tools Configuration:
The External Tools Configuration window will appear. Select Programs and then click New Launch Configuration:
This will create a new launch configuration. Enter a name of the configuration in the name field:
In the Location field enter the path to the Open Finder, "/usr/bin/open" without quotes:
In the Arguments field enter the following argument, "${container_loc}" with quotes:
Click Apply. It should look like the following:
Switch to the build tab and deselect Build before launch:
Switch to the Common tab and select the External Tools checkbox in Favorites. Click Apply again and close out of the window.
You are done. Now to use:
Select a file or folder in Eclipse Package Explorer.
Click the disclosure icon to the right of the External Tools icon:
Select the Open Containing Folder from the drop down menu:
You're file or folder should open in Finder.
PRO TIP: After you use the external tool once you can click the External Tools icon again and it will run the last used external tool. In other words, you won't need to select it from the pop up menu each time.
You can also look up the source directory by right clicking on the project, going to properties, and looking at "Location: ... "
So with eclipse I would instruct it to open html/css/js files in textmate, and pretty much just use if for the php side of things.
Would like to do a similar thing with nb if possible.
Any thoughts?
Best,
Bob
There exists a Path Tools plugin for Netbeans. It has a command "Edit path...". With this you can select a file in the tree, click "Edit path..." and the file will be opened in an external editor.
You can customize the external program which is called under "Tools" -> "Options" -> "Miscellaneous" -> "Path Tools" -> "Edit Commands For File" .
You can't assign it to specific file types, but at least you can open files without leaving Netbeans.
The webpage of the Path Tools plugin looks not very active, but it works in Netbeans 6.9.1 without problems (Works on My Machine).
It also has other useful actions:
Copy Paths Action Copy the full paths of the files/folder of selected node to the clipboard.
Explore Action Launch the OS File Explorer
Shell On Path Action Launch the OS shell
Edit Action Launch the editor
This plugin should be integrated to Netbeans.
Thank you for the help on this.
Here is a way for the Path Tools 'Edit' toolbar button to pop up the Windows 'Open With...' dialog box for the selected file.
In Options, Path Tools... 'Edit Commands' 'For File' - change the command to this:
rundll32.exe C:\WINDOWS\system32\shell32.dll,OpenAs_RunDLL {path}
(Edit: I forgot to say this is for XP - idea is the same for newer Windows)
If you don't want to deal with manipulating plugins and configs, you can do it this way (valid for version 8.2):
Go to Tools > Options > Kepmap
search for "path"
It defaults to Alt + Shift + L
use that command in any editor window to get the path for the file, then simply open that path in whichever editor.
I agree it's not as smooth and savvy as having a readily-available "open in external editor" command, but it's almost there.
I have created a couple of java working sets for a project in my workspace and want to share them with other people (using different workspaces). Is there a way to export them?
You can try and export (as in "copy to another people workspace metadata directory"):
</path/to/.metadata>\.plugins\org.eclipse.ui.workbench\workingsets.xml
This is the file referencing your working sets.
z0r adds in the comments:
my team mate replaced his workingsets.xml with my version of the file, and it worked well.
However, you must exit Eclipse before replacing the file, because Eclipse will overwrite it with the old version when it exits.
I think you only need to do this once.
download the AnyEdit addon:
Description | Download page
and then use the following work through:
Via the menu bar: File > “Export…”
Select “General” / “Working Sets”
Click “Next >”
Select the working set(s) you want to export and where you want to export the file.
Click “Finish” to perform the export.
In Eclipse Indigo the working sets export has moved to Export -> Team Project Set and there is a check box top left to export working sets.
Although, File → Export → Team → Team Project Set is the correct way to export working sets, you could write an Eclipse External Tool.
External Tools
Open a new dialog by navigating:
Run → External Tools → External Tools Configurations…
Select Program and click the New button to create a new configuration.
Note: You will only need to use the "Main" tab.
Give the tool a title e.g. "Export Working Sets"
Windows
Location: ${env_var:SystemRoot}\System32\cmd.exe
Working Directory: ${env_var:USERPROFILE}\Documents
Arguments:
/c copy /y ${workspace_loc}\.metadata\.plugins\org.eclipse.ui.workbench\workingsets.xml workingsets-${current_date}.xml
Linux
Location: /bin/cp
Working Directory: ${env_var:HOME}/Documents
Arguments:
${workspace_loc}/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml workingsets-${current_date}.xml