Make PyCharm recognize string as path - python-3.x

I am working with Python 3.4.
When I use IDLE and start typing, e.g.,
my_main_folder = "C:/Us"
in the editor window, and then press Ctrl + Space, IDLE offers me all subfolders of C:, and if I press Tab, the string is completed to "C:/Users".
That means that IDLE (or Python Shell) is able to recognize a string as a path.
How to make PyCharm (Community edition) do that?

Its not able in Community Edition Pycharm. But it can be done in Professional Edition Pycharm. I would suggest you to move to Professional Edition.
Does PyCharm have autocomplete file path?
BUT,There is a work around for it in Community Edition.
Place caret in such place and press Alt+Enter -- see if you will have "Inject language or reference" option in appeared menu. If it's present -- use it and choose "File Reference" there.
NOTE 1: this option may not be available if string is empty or has less than 2 characters in it
NOTE 2: this is temp injection -- AFAIK it will be lost after IDE restart (and you will need to do it again if needed)
Otherwise: select desired file in Project View panel and use "Copy Reference" -- it will copy a file path relative to the project root -- you may only need to add leading "/"...
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206574619-Autocompleting-relative-paths

After searching I found this answer:
can we tab through paths, in the same way you can in the terminal?
No, it's not posible:(
I wrote a plugin for Komodo called AutoCode that allowed me to ALT+Click on files in the Project view, and it would automatically resolve the right path
You can use 'Copy reference' in file right-click menu to copy file path relative to project root to clipboard. But this action doesn't unfortunately take resource roots into account
However, you can use CNTRL-SPACE twice and it will present a list of paths and files, example:
For a detailed description of this information see here

Related

Remove a file from the compile, mark it as text

Today's Android Studio Tip of the Day...
You can exclude any file from your project. As a result, such a file will be ignored by indexing, inspection and code completion.
In the Project tool window, select the file you want to ignore, and choose Mark as plain text in its context menu.
If necessary, you can always return the file to its original type using the Mark as context menu command.
If this means View >> Tool Windows >> Project I could not find this useful functionality. Any pointers??
Yes, it's in View → Tool Windows → Project. But not every file has this option. XML-files do, Java-files do not. The option is right under "Delete...".

Adding own files/packages to a custom anaconda environment

I have a custom anaconda environment which I am using to run a program which is dependent on files in another directory. How do I add these files to the environment like I would do with a system interpreter by adding the paths to PYTHONPATH variable in system variables?
I did not need to add the custom files to the virtual environment configuration. I was using the Pycharm Python editor and found a better workaround by adding the paths to the selected interpreter (which in this case was the interpreter for the virtual python environment that I was using).
Go to File —>Settings—> Project: Project name—>Project Interpreter
Next to the project interpreter, click the little gear icon.
Click on Show all. A window should pop-up.
On the right side of the window, there’s a toolbar containing 5 options starting with the plus icon.
Click on the last icon with the file symbol. Another window should open.
Here click on the plus symbol on the top right toolbar.
Go to the directory that you want to include to use in your code and click Ok to add them to the interpreter path.
Repeat for any other directories or files that you may need to have.
This solution with Pycharm worked out pretty well for me since I only needed to reference those files on my computer for that particular project.

How to search specific filename in Visual Studio Code?

For example, I want to search a file whose name is "module-product.js" to rename it.
But there are lots of files whose names started with "module-".
How to quickly find the specific file in Visual Studio Code?
Ctrl+P and enter details into the popup that you would like to search for! You can prefix the search with # to search for a function.
Others (on a mac) include;
⌘+T Show all Symbols
⌃+G Go to Line...
⌘+P Go to File...
⇧+⌘+O Go to Symbol...
A secret feature of VSCode is the explorer filter.
Cmd-Shift-E (or clicking the sidebar) focusses the explorer. Typing some characters shows only files or directories whose names contain the given characters. Esc clears the search.
As usual, you can use Up- and Down-Arrow to navigate the displayed file list and Cmd-Down to open the currently highlighted file.

Is there a way to use Sublime to show file previews in Windows Explorer for certain files?

I'd like to be able to preview all plain-text files in the Windows File Explorer Preview Pane. To illustrate, here's what sublime files currently look like:
As you can see, Context.sublime-menu is highlighted, but a preview doesn't appear. They're just plain-text files though - you can open them in Notepad. Is there a way to tell windows "Use notepad (or sublime) to view this type of file the preview pane"?
Thanks to #KeithHall's link - while it didn't work for me - got me started on a pretty long path to finally figuring this out. And finding a better solution than I thought existed.
In short, simply install the Delphi Preview Handler. Which pretty much gives you an IDE in the preview pane. It's pretty simple to use and just awesome.
After installation, if you click on a .js file in Windows File Explorer you can immediately see a different preview pane.
Registering Other Extensions
The Preview Handler doesn't compensate for all plain-text files unfortunately, so you're gonna have to manually add the sublime extensions and any other extensions in the Registry Editor.
Here's the bird's-eye view of this process:
Find the key/value that instructs Windows to use Delphi as the preview handler for .js files.
Copy the key/value
Apply that to each extension you want to preview.
Here's more in-depth instructions:
First, you need to find the ID of the Preview Handler, and its Default Value
win + rregedit > expand HKEY_CLASSES_ROOT
Find .js and expand it.
.js should have a subkey named shellex, expand that
You need to recreate this shellex key for each extension you want to add, so copy its contents:
shellex should have a sub-key named with a bunch of numbers, letters, and dashes, this is the ID of the preview pane (I think)
Right-Click that > Rename > Copy > Cancel
Open Sublime > Create a new file > Paste
Go back to the Registry Editor, Click that ID subkey, and a String value called (Default) should appear in the right side of the window.
Double-Click that
Copy > Cancel > Paste in sublime. This is the ID of the Preview Handler (I think).
At this point there should be 2 IDs in the sublime file.
Now You're ready to add these same values to other extensions.
Find the extension(s) you want to change. For me it was all the sublime file-types.
Right-click > New > Key > call it shellex
Go to sublime, copy the first value
Right-click shellex > New > Key > Paste
Go to sublime, copy the second value
Click the new key and make it's default value that 2nd id.
So it should look similar to this:
v .sublime-commands
| v shellex
| |- {823BD1D4-...
And in the right side of the window:
Name Type Data
(Default) REG_SZ {AD9955...
Sources:
This Answer by #rxantos pointed me in the direction of the Delphi Preview Handler.
I spent about an hour looking for this app but never found it.
This Answer by #tvj247 is perhaps a more simple solution, but my HKey structure didn't match his (I'm using Windows 10).
And as for fiddling with the Registry, that was trial, error, and comparing sublime extension keys to js, html and css.

How do I get rid of "Current text selection cannot be opened in an editor" in Eclipse?

Sometimes, I get this message in the status bar when I press F3 on a Type in a Java editor:
Current text selection cannot be opened in an editor
When I copy the selection into the clipboard and use Ctrl+Shift+T to open the "Open Type" dialog, I can paste the value and it will display the type and I can open it. The type is on the class path (no compile errors).
In other Java editors in the same project, F3 / Ctrl-Click works.
In the "broken" editor, it only works on internal fields and methods. For internal fields, it only works in the place where the field is defined. All places where a field is used are dead. "Mark Occurrences" works, though.
How do I get rid of it?
So far, I tried:
Close and open the editor
Clean the project
Clean all projects
"Update Project..." in the Maven context menu
Restart Eclipse
Restart Eclipse with -clean
This happens on Eclipse 3.7.2 with m2e 1.3.1 installed.
[UPDATE] This seems to be a bug somewhere in the depths of m2e and JDT. Usually, it appears when you have several projects (Maven multi module / reactor build) and the modules MA, MB and MC depend on each other:
MC depends on MB depends on an inner parameterized type X.Y<T> of MA.
and you have closed the module MB. On the classpath of MC, this will look like so:
MB.jar
MA
That is MB exists as a JAR on the classpath while MA is imported as an Eclipse project from the workspace.
In this situation, Eclipse gets confused when reading .class files in MB.jar which need inner parameterized types from MA. My guess is that it needs the type from MB.jar, parses it which tells it of the dependency to the type in MA which it then tries to parse only to find that the type parameter for T can't be resolved since parsing of MB isn't finished, yet.
There are three fixes:
Close MA. That will import everything as a JAR.
Open the project MB.
Make the inner type a toplevel type
[OLD]
If this happens, try these steps in order of increasing despair:
Close the editor and open it again.
Clean the project
Close the project and open it again.
Restart Eclipse
If all that fails:
Export your preferences
Exit Eclipse
Delete (or rename) the folder .metadata in your workspace. It's an invisible folder on some OSs but it's there.
Start Eclipse again
Import your preferences
Import all projects again. For this, select the workspace. Eclipse will then list all projects in the dialog and you can select all of them at once.
Related:
Bug 430605 - [select] Current text selection cannot be opened in an editor
There is a bug in Eclipse (in Luna at least) for a very specific workflow, which might not be the answer to this specific question, but might be helpful for others.
If you perform an import into the src (meaning src folder has focus before performing import) folder from an extracted jar (as source code), and you place breakpoints in the nested *.java files in the nested packages, it won't hit those breakpoints. In order to get things to work, you must keep hitting F3 instead of using "Open Declaration" to get to the *.java file you want to set a breakpoint in, then add the breakpoint by double clicking in the far left margin. Then Run > Debug As > Java Application.
this issue comes because eclipse workspace created by eclipse unable to load source code properly into its cache
please follow below steps to resolve this issue
goto eclipse workspace
for eg
i have loaded source code on below path:
C:\Users\ABCD\WorkingSourceCode7july (it will have .metadata)
just remove current working folder (WorkingSourceCode7july)
after that open eclipse again and create new working folder(WorkingSourceCode7july) and try to import same source code
i hope this may resolve the issue
this worked for me

Resources