sublime text suffix mapping - osx-snow-leopard

is it possible to map the suffix of files opened by sublime text 2 to be similar to other languages to get the text coloring? for example, when i open a *.cu file, this isn't recognize by sublime text as a valid file extension, so it opens the file and there are no text coloring in there at all. however if you open a php or c++ files, the the file will be recognized as valid file extension, and there will be text coloring, making it much easier to read.
I know text wrangler has this feature, and you cam map *.cu file extension to be like c++ so when you open a .cu file, the text coloring will be similar to a c++ file.

Yes it is.
Please see:
http://opensourcehacker.com/2012/05/11/sublime-text-2-tips-for-python-and-web-developers/
->
Map file formats to syntax highlighting

Related

how to get the type of the file before its compression

For example, if we have the following file: file.txt that after the compression is now file.new (new is the new extension) , how to obtain that .txt extension, that is forgotten?
I need that to decompress the file.
In general, if you lose the file name extension you can't get it back. It's as simple as this.
However, there might be chances depending on the compression format. Some formats do store the original file name (along with other informations) in the compressed file. And the "decompressor" will be able to recreate those properties.
Anyway, it's good practise to name a compressed file with an additional extension, in your case file.txt.new.
Oh, and you don't need to know the file name extension to uncompress the compressed file. Just uncompress it and give it a temporary name. As #MarcoBonelli said, file contents and file name extensions have no fixed relation. They are just a convention to handle them conveniently.
For example: You can rename a EXE to DOCX. Windows will show the Word icon but it is still an executable. Windows will not attempt to run it, though.
To know what a file contains can be difficult. The magic number Marco linked to might give you some hint.

Is file format different from file extension?

I don't understand how files are stored. I opened my text editor, wrote down some gibberish and saved it as .pdf, and then tried to open it with a pdf reader. The pdf reader could not open it. Someone please explain what happened here?
Let's say you have a folder system in your office, that says "English documents go into brown folders; Spanish documents go into pink folders; French documents in red folders; Japanese documents in white folders;..."
If you put "これは英語じゃね〜よばか" into a brown folder, it doesn't make the text English. It just means you put it into a wrong folder. If you put "egu egu egu egu egu" into a Japanese folder, it doesn't stop being gibberish.
File extension is a part of a file name that we use by convention to mark what kind of content a file has (kind of like a folder colour). File format is the structure of the content a file has (kind of like knowing what language to use to read the paper within).
Extensions are primarily for users, so we know what each file has, and also a shortcut so OS can open a file with an application it thinks is suited for it (just like one could see a brown folder and decide it should go to the English-speaking employee).
Just like a Japanese speaker will be able to read a Japanese text in a brown folder (if explicitly handed one), a PDF reader will be able to read a PDF-format document, whatever the extension (if you make the PDF-reader open it, rather than relying on the OS to figure out the correct application). Just like no-one can read "egu egu egu egu egu" despite its folder's claims of it being Japanese, the PDF reader is confused to find a non-PDF-formatted content inside a .pdf extension file.
File extensions and file formats are often spoken about
interchangeably. In reality, however, a file extension is just the
characters that appear after the period, while the file format speaks
to the way in which the data in the file is organized.
So, in your example, you have created file in txt format and manually updated extension to .pdf. PDF reader thinks that it can open that file (since it has .pdf extension), but it wasn't able since it's formatted as txt.
To sum, you can change extension, but no format. In order to change format, you have to use some kind of converter.
File extension is part of file name so it's just a label. You won't change file format by changing its label just as changing the name of the shortcut on your desktop from "MS Word" to "Battlefield 2" won't magically allow you to play this game for free:)

Why some codes are colourful, some aren't in Sublime Text 3?

I had created angular quick start but as I mentioned in title some codes aren't colourful. How can I solve this?
For example:
By default sublime check extension of file and set highlighting for language (based on extension). For your case he knows that .js is javascript but he does not recognize .ts extension so he choosed plain text.
If sublime does not recognize which language the file has you can still define language in file manually.
In the right bottom corner in Sublime you can see for second file the "syntax highlighting" is set to Plain text.
Click on plain text and select javascript for example:

Save in Sublime Text with Another Extension

In Sublime Text 2 & 3, whenever I save a file with one extension, or without an extension, then save it with another extension later, the syntax colors seem to stay with the first extension. For example, when I save what I mean to be a JavaScript or PHP file without an extension by accident, then Save As with the correct extension, the text stays all black.
Is this supposed to happen? Is it because the file isn't actually saved as the 2nd extension the next time? Most importantly, is there a way to save the file with the correct extension without creating a new file & copying all the text over?
you can set the syntax manually as follows.
click HTML and you will see all the syntaxes, you may choose whatever you want, or you can do it in the command palette by type ctrl+shify+P and type syntax and you can do the same thing.

Search up include hierarcy

Is there an easy way to do a text search on a c file that goes up the include tree (including files in the include search locations)? Preferably in eclipse.
check for ctags, Ctags generates an index (or tag) file of language objects found in source files that allows these items to be quickly and easily located by a text editor or other utility.
http://en.wikipedia.org/wiki/Ctags
http://ctags.sourceforge.net/

Resources