Whenever I open a .m file the default syntax is objective-c but I want to change that to matlab. So when I open a .m file I go to
view -> syntax -> open all with current extension as..
and choose matlab. After that if I open another .m file the default syntax is matlab. But if I close sublime and open it again the default syntax is back to objective-c.
I added objective-c to ignore syntax list but now it opens .m files as plain text. Is there another way to set default syntax for a file extension?
In sublime3, view -> syntax -> open all with current extension as.. works if you close then open sublime.
I'm not sure why Sublime is doing this, but there's a way around it. Since you're using ST2, it's quite easy. Select Preferences -> Browse Packages... to open your Packages folder, and open the Objective-C subfolder. Open Objective-C.tmLanguage in Sublime as an XML file, and comment out (or remove entirely) Line 7:
<string>m</string>
Save the file and close it. Next, open Objective-C++.tmLanguage and do the same thing to Line 8:
<string>M</string>
Save and close that file as well. Finally, just to make sure your Open all with current extension as... command worked, go to Packages/User and check for the existence of a file called MATLAB.sublime-settings. Open it as a JSON file, and double-check that its contents are as follows:
{
"extensions":
[
"m"
]
}
If for some reason the file doesn't exist, create it with the above contents and save it. You should now be able to open any .m file and have the syntax automatically set to MATLAB.
Note for Sublime Text 3 users:
ST3 does not store its default packages in Packages anymore, instead they're in the Installed Packages folder (its location varies by OS and type of install) as zipped .sublime-package files. To access the contents, install #skuroda's PackageResourceViewer plugin to seamlessly access the contents of these files. Once installed, open the Command Palette (CtrlShiftP on Windows/Linux, ⌘ShiftP on OS X) and type prv to bring up the PackageResourceViewer options. Select Extract Package, scroll down to Objective-C, and hit Enter. You can now follow the directions above for opening the Packages/Objective-C folder and editing the .tmLanguage files. The Packages/User directory is a regular directory, so you don't need to extract it to verify the contents of MATLAB.sublime-settings.
I think why this is happening, at least in Sublime 3 (v3.2.1). After using PackageResourceViewer: Extract Package to extract Matlab package, I found that in Matlab.sublime-syntax in Line 6:
- matlab
As .matlab is not an extension for matlab functions and scripts, after I changed it to - m, Sublime shows .m files in MATLAB syntax.
Related
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.
Now my default file type of Visual Studio Code is Plain Text.
If I save a new file with name like a.in, it will save as a.in.txt. I have to change the dropdown to All Files.
I find the same problems in github: 1, 2. However, they seem not solve my problem.
This is not possible in the general case in VSCode.
The issue is that you cannot assign "no extension" to a language, and as per the links you mentioned, the All Files (*.*) option is disabled by upstream (electron).
Therefore, you will either have to remove the extension manually, OR you can create the file first (using the terminal, Explorer, an extension, etc.) and then open that existing file.
There is a way to change the default extension (but not to All Files)
Add the following line to your settings.json
"files.defaultLanguage": "<language>",
Replace <language> with the language of your choice.
Now, whenever you make a new a file, the default file language will be <language>.
A special value for <language> is ${activeEditorLanguage} which is the language of the file last opened (useful if, say, you copy a piece of code from one file to save as another).
Unfortunately, this does not fully answer the question, but provides a partial solution.
Kindly help me to resolve the following points:
- How to see the error?
- as I'm writing c code : the standard text colour for header files, variable types etc .. not able to see.
Please help me to resolve the same.
Thanks in advance!
Because you have just called your file Printf (with no file extension) Eclipse does not know that it is a C program and has just opened the plain text editor.
Rename your file to be Printf.c (add the .c file extension). Eclipse uses the file extension to determine what sort of file you are using.
Since you have already opened this file using the plain text editor you will have to right click on the file and choose 'Open with` and select the C editor. You only have to do this once as Eclipse will remember your choice.
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:
I want to open a file using some kind of fuzzy searching, and I'm pretty sure I've seen this functionality inside Sublime Text, but for some reason I can't find any mention of this anywhere.
I want to open the command pallet and be able to type a file name in there, and if the file is close, It will open the file for me, if it's open, it will activate it's window and group.
Is this possible?
I see you already found ctrl+p, but the original announcement of this feature has some good information on usage so I thought I'd post it.
The biggest change here is that the Ctrl+P dialog has been reworked into a more general "Goto Anything" popup. From this, you can:
Type, to search through files (open files, recently closed files, and files in open folders)
#foo, to search through symbols in the current file
:foo, to go to the given line number
#foo, to do a fuzzy search in the current file for foo
These can be combined: "foo#bar" will search for the file that best matches "foo", and go to the symbol in that file that best matches "bar". "foo:100" would go to line 100 of the same file. You can use this to preview a location in another file, then hit escape to go back to where you where.