I'd like to password protect a text file. Not necessarily a
.txt file - just a file that's got text in it that I can edit with a standard text editor. I'd like to set a password and be prompted for it every time I open the file in any app. What's the best way?
You can put the file into an encrypted disk image.
You now have a password-protected disk image that you can save any kind of file in.
Assuming you're the file's owner, a built-in and system-wide way to do this would be to adjust the file's permissions so that only a specific user or users (I'm assuming you want to lock the file so only you can view/edit it) can read or write to the file.
As Mark pointed out in the comments, however, this only protects you if:
Making Coconut Man's solution by far a better one. I'll leave this answer here as an alternative that may be helpful in similar situations.