How do I get Google Drive to open text files with arbitrary extensions as text files?

I have text files on Google Drive that do not end with the .txt suffix (such as: .r, .bas, .awk...).
I want to view them using the Drive Notepad app, but it does not recognize the files as text.
Is there a way I can get these files to be recognized as text?


Solution 1:

If you just want to view the files you can do the following:

  1. Save the file with a .txt extension, i.e. filename.bat becomes filename.bat.txt
  2. Add it to google drive
  3. Remove the .txt extension, filename.bat.txt goes back to filename.bat

Google determines the context type based on the extension and retains that through future file renamings, so you'll be able to view it even after changing back to the original extension.

Solution 2:

From Support (Drive Notepad) :

If you want to open another type of file you can request it in the Google+ community for Drive Notepad Users.

For only viewing, you can use on Chrome the extension CodeViewer.

An alternative commercial editor, Neutron Drive is not free ($28/year), but it integrates very well with Google Drive.