When you press Ctrl+p Sublime will open popup when you can easily find the file. Sublime auto detect the file location in both situation when you press / or space between file path parts.
In Zend Framework all classes has name within follow template: Namespace_Module_Other_Part_Of_Class_Location, how can I make Sublime understand the _ as a path separator when I press Ctrl+p and copy past the class name there?
So the above class should be recognized on location: Project/Namespace/Module/Other/Part/Of/Class/Location.php
I'm still looking for the solution of it. Even if the file search is hard-coded in Sublime 3, and you have a workaround to make it works, maybe to write some plugin? you are welcome.
Thank you.
You can do this with a simple plugin and key binding. Select Tools -> New Plugin... and replace the contents with the following:
import sublime
import sublime_plugin
class UnderscoreToSpaceCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command('copy')
clipboard = sublime.get_clipboard()
clipboard = clipboard.replace('_', ' ')
sublime.set_clipboard(clipboard)
Save the file as Packages/User/underscore_to_space.py where Packages is the folder opened when clicking on Preferences -> Browse Packages....
Next, create a custom key binding for the command. Select Preferences -> Key Bindings-User and add the following:
{ "keys": ["ctrl+shift+c"], "command": "underscore_to_space" }
If the file is empty when you open it, surround the above line with square brackets [ ]. Save the file (it will automatically save to the correct location), and you're all set.
Now, all you need to do is select the text you want to convert, and hit CtrlShiftC. This will copy the text to the clipboard, replace the underscores with spaces, and put the modified text back in the clipboard. You can now hit CtrlP to open Goto Anything... and paste in the modified text with CtrlV.
If you prefer to have the underscores replaces with forward slashes /, just change the clipboard.replace() arguments from ('_', ' ') to ('_', '/').
To get to the class definition you are looking for there exist several plugins doing "code intelligence". The plugins are language specific.
The most popular is SublimeCodeIntel which provides Jump to symbol definition functionality. SublimeCodeIntel claims to do this for PHP too. However, who to setup this for your project should be another question.
Some more options for possible source code static analysis in Sublime Text 2 in this blog post:
Related
VS Code is aware of many file types, but I cannot find any information on where to see all file types it currently understands.
I want to see which file type is associated with which language.
If I view the file associations it's totally blank:
I want to add a new association. I want to associate *.inc as a restructured text file. But figuring this out is a guess right now, what is the "code" for the restructured text language?
Is it rst:
Or is it "restructured text"? Or another value. My VS Code currently associates *.rst files with restructured text, but I cannot see that configuration anywhere.
The easiest way I've found for a global association is simply to Ctrl + k m (or Ctrl +Shift + P and type "change language mode")` with a file of the type you're associating open.
In the first selections will be the option "Configure File Association for 'x' " (whatever file type - see image attached). Selecting this gives you the option to choose the language and will then make the filetype association permanent.
screenshot
This may have changed (probably did) since the original question and accepted answer (and I don't know when it changed) but it's so much easier than the manual editing steps in the accepted and some of the other answers, and totally avoids having to muss with IDs that may not be obvious.
Answer 2
In VScode, you can add persistent file associations for language highlighting to your settings.json file like this:
// Place your settings in this file to overwrite the default settings
{
"some_setting": custom_value,
...
"files.associations": {
"*.thor": "ruby",
"*.jsx": "javascript",
"Jenkinsfile*": "groovy"
}
}
You can use Ctrl+Shift+P (or View -> Command Palette from the menu) and then type settings JSON. Choose Preferences: Open Settings (JSON) to open your settings.json.
To find the proper language ID, use Ctrl + Shift + P (or View -> Command Palette from the menu) and then type Change Language Mode. You can see the language ID in the list, e.g. type docker to find the language ID for Docker files (dockerfile). In the first entry in the example above, .thor is the file ending, ruby is the language ID.
Are there any extensions/features in vs-code which could let me know where the current file is imported? I usually do a global search of the filename but it is time consuming when the file name is similar to any variable or there are similar named files.
You can do a right-click on every function / variable or class. Then you choose "Find all references" to show where each function / variable or class is called.
For this you do not need an extension, because it is a standard feature of vscode
- find unused exports in project:
you can use this extension in vscode to find all unused exports
+ find name references (e.g. used exports) in project:
click on name then press shift+alt+F12
NO EXTENSION REQUIRED
Yes, We can find the references of a file in VSCODE like this:
Right-click on the file and then select Find References.
VSCODE will show all the references/imports of the file.
image reference
Right-click > Go to References (Shift + F12)
There is also an extension to change the appearance of how references show https://marketplace.visualstudio.com/items?itemName=jrieken.references-plusplus
If you are limiting your search to the current open workspace / folder, you can
do a search for 'import' using the magnifying glass or pressing ctrl+shift+s
open the results in editor by either clicking the link that says 'Open in editor' or by pressing alt+enter
In the document that opens, search for the name of your module.
In this way you will discover all of the imports that involve your module, regardless of whether you have used 'import mymodule' or 'from mymodule import myfunction' or anything else. I'm specifically thinking of how I'd structure a python project, but if you are using another language, you can alter the search in a way that works for the way your language does imports.
I searched in vscode site but I couldn't find information on the following:
Is there any way to search definition in other files.
For example:
In sublime text I can open command pallette (ctrl+p) and write 'User.php#delete' - this will find the method and if i click enter I will go the the specific file and in the line where method 'delete' is.
Does the functionality exist in VSCode (or with extension).
Thanks
There are multiple options to search function/definition.
According to your convenience, you can choose one of the below options :
Best shortcut: Ctrl+Shift+O and type your function name.
Press Ctrl+P for "quick open", then you can use # or #: The latter is handy to see all the symbols in the file grouped by classes, constants, fields, methods
Press Ctrl+T to searches across files, not just the current file.
Hover the method and press crtl. The method will be underlined and show a tooltip with definition. Mouse left click = go to definition.
yes, in command palete enter # symbol (without preceding >) end method name.
I tried to get Eclipse to convert all of the tabs in my project to spaces like this:
Java Editor:
Click Window » Preferences
Expand Java » Code Style
Click Formatter
Click the Edit button
Click the Indentation tab
Under General Settings, set Tab policy to: Spaces only
Click OK ad nauseum to apply the changes.
And now my code is formatted without any indentations within if and for blocks, like this:
private void addAppointment(Resource resource) {
if (resource != null) {
Appt appt1 = new Appt();
appt1.setTime(new Date());
resource.setAppointment(appt1);
}
}
I really don't want to have to manually fix this in the hundreds of files in the project, how can I format to indent within if and for blocks in the whole project?
I should also say that the "Statements within blocks" checkbox in the active Formatter profile is checked. The preview it shows has a for block with an indented body, so I have no idea why that isn't being applied to my project.
#gnac provides some good options, in addition to:
Similarly you can use ctrl+shift+f (Source->Format) on each class to format it on the fly
You can select the project(s) and do Source menu -> Format to format everything in that project in one go. (No keyboard shortcut for it AFAIK.)
So once you set your formatting options you have a couple of options. You can set the preferences to format your files when saving.
Preferences->Java->Editor->Save Actions
However, if you have a lot of files this will be a pain as well. Similarly you can use ctrl+shift+f (Source->Format) on each class to format it on the fly, again having to do it on each file individually.
Inside Eclipse you can use Search->Find, enter "\t" in the text box and select the "Regular Expression" check box and then click the "Replace..." button. When the search is done, it will ask you what to replace it with. Enter 4 spaces into the "With" text field. Click Preview to see what it will do, or OK to make the changes.
I would use a find and sed to find all of the java files in a directory and replace the tabs, although this is outside of eclipse
find -iname ".java" -exec sed -i.orig 's/\t/ /g' {} +
If you're not on Linux you could use cygwin to do the same on Windows.
How would you copy the code from this example page
http://framework.zend.com/manual/en/learning.quickstart.create-layout.html
(Below the text "Now that we've initialized Zend_Layout and set the Doctype, let's create our site-wide layout:" )
A simple copy paste will also copy the line number or #. Any tricks ?
I hate these line numbers as well. The way I do it:
Copy the text to your favorite text editor (notepad won't do, Word for example would) and block-select using the ALT Key.
Let me give you an example with Notepad++. here I copied text from the said site with all line numbers included. Now I just hold the ALT button and select normally with my mouse (or using SHIFT+arrow keys). The result of me selecting only the code sans the line numbers you see in the following screenshot:
Now I could just copy this code to a new editor.