Eclipse : Error While Running the Program - eclipse

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.

Related

How to set default file type to be All Files(*.*) in VS Code?

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.

setting default syntax for sublime doesn't work

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.

Sublime text 2 - find file by class name in Zend Framework

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:

Is there a way to copy code from eclipse including ine numbers

I am writing a little bit of documentation and code explanation. I would like to copy code from eclipse including line numbers, so that it becomes easier to reference the code in the text.
Is there any way to do this in eclipse or some other IDE, editor?
Since Eclipse 3.4 and bug 19602, you will print the line numbers if you have activated them on the Eclipse editor.
alt text http://img706.imageshack.us/img706/7605/eclipseshowlines.png
Printing a source will give you:
alt text http://img341.imageshack.us/img341/9899/eclipseprint.png
You can do it by printing a PDF of source file, then copying source with line numbers from the PDF document.
It works for me with eclipse PDT + CutePDF, it should also work with Acrobat PDF printer
Another not-so-clean work-around to achieve this. This is specific to the Subversive plug-in.
3 steps to follow:
Delete the piece of code you need to copy and save the source file.
Right click the file and chose option Team -> Create Patch.. and save it to a file, say copy.patch
Undo (Ctrl + Z) the changes to revert the deletion done in step 1 and save the source file again.
Open the patch file and use the contents.
This also includes the file-name (if desired) along with the line number and retains the indentation.

How can I clean source code files of invisible characters?

I have a bizarre problem: Somewhere in my HTML/PHP code there's a hidden, invisible character that I can't seem to get rid of. By copying it from Firebug and converting it I identified it as  or 'Zero width no-break space'. It shows up as non-empty text node in my website and is causing a serious layout problem.
The problem is, I can't get rid of it. I can't see it in my files even when turning Invisibles on (duh). I can't seem to find it, no search tool seems to pick up on it. I rewrote my code around where it could be, but it seems to be somewhere deeper in one of the framework files.
How can I find characters by charcode across files or something like that? I'm open to different tools, but they have to work on Mac OS X.
You don't get the character in the editor, because you can't find it in text editors. #FEFF or #FFFE are so-called byte-order marks. They are a Microsoft invention to tell in a Unicode file, in which order multi-byte characters are stored.
To get rid of it, tell your editor to save the file either as ANSI/ISO-8859 or as Unicode without BOM. If your editor can't do so, you'll either have to switch editors (sadly) or use some kind of truncation tool like, e.g., a hex editor that allows you to see how the file really looks.
On googling, it seems, that TextWrangler has a "UTF-8, no BOM" mode. Otherwise, if you're comfortable with the terminal, you can use Vim:
:set nobomb
and save the file. Presto!
The characters are always the very first in a text file. Editors with support for the BOM will not, as I mentioned, show it to you at all.
If you are using Textmate and the problem is in a UTF-8 file:
Open the file
File > Re-open with encoding > ISO-8859-1 (Latin1)
You should be able to see and remove the first character in file
File > Save
File > Re-open with encoding > UTF8
File > Save
It works for me every time.
It's a byte-order mark. Under Mac OS X: open terminal window, go to your sources and type:
grep -rn $'\xFEFF' *
It will show you the line numbers and filenames containing BOM.
In Notepad++, there is an option to show all characters. From the top menu:
View -> Show Symbol -> Show All Characters
I'm not a Mac user, but my general advice would be: when all else fails, use a hex editor. Very useful in such cases.
See "Comparison of hex editors" in WikiPedia.
I know it is a little late to answer to this question, but I am adding how to change encoding in Visual Studio, hope it will be helpfull for someone who will be reading this sometime:
Go to File -> Save (your filename) as...
And in File Explorer window, select small arrow next to the Save button -> click Save with Encoding...
Click Yes (on Do you want to replace existing file dialog)
And finally select e.g. Unicode (UTF-8 without signature) - that removes BOM