Edit contents of file from Finder with text editor
The "foo.bar can't be opened because it is from an unidentified developer" error is because of Gatekeeper. You can disable Gatekeeper from System Preferences:



Selecting "Always Open With" from the "Open With > Other..." dialog only changes the default application for the selected files. You can change the default application for all files of a type from a Show Info window:



You can add a context menu item for opening files in TextEdit by creating a service like this with Automator:



If you have the Powerpack for Alfred 2, you can also create a workflow like this:



You can use duti to make TextEdit the default application for plain text files without an extension and executable scripts. Install Homebrew, run brew install duti, save

com.apple.TextEdit public.plain-text all
com.apple.TextEdit public.unix-executable all


as ~/.duti, and then run /usr/local/bin/duti ~/.duti.