After searching around these forums a bit I finally found a solution to problems I was having with Nautilius.
Nautilus reads files in order to determine the file type, rather than basing it off the extension. While in theory this is a great idea, it fails in a couple of places. Notably with plain text files, many scripts/programs are parsed incorrectly. For example, a PHP script is only parsed as such if the first line contains <?php which is not always the case. This causes a few unwanted effects like opening with different apps by default and files jumping around in the file list window when ordered by type.
The solution: Change how Nautilus parses the file types! The rules it uses are all listed in the file /usr/share/mime/packages/freedesktop.org.xml. I've provided two solutions: the former for people familiar with XML and Linux in general; the letter being more detailed.
1. Back up the freedesktop.org.xml.
2. Open the freedesktop.org.xml file as super-user.
3. Find the mime-type that your file is being incorrectly parsed as.
4. Remove the <magic> element and its contents, or alternatively change the <match> elements.
5. Run sudo update-mime-database /usr/share/mime
Don't forget to back up first:
You can open the file with the command (& is so you can continue using commands with the file open)
sudo cp /usr/share/mime/packages/freedesktop.org.xml /usr/share/mime/packages/freedesktop.org.xml.bak
If you search for "*.php", you should see a section similar to this. To keep it short I've removed the translations but you should leave them in the file.
sudo gedit /usr/share/mime/packages/freedesktop.org.xml &
The part in bold is what will decide the type. For each mime type, it is listed in <magic> tags. So for your chosen file type, all you have to do is remove the <magic> element and its contents.
<comment xml:lang="az">PHP skripti</comment>
[... more translations here ...]
<match value="<?php" type="string" offset="0:64"/>
Once you're done, save the file and run this command:
The same process should apply for all file types. To stop PHP files being parsed as HTML documents, you will need to remove the magic element from the HTML mime type as well.
sudo update-mime-database /usr/share/mime
Hope this is useful to people!