To password protect a file in vim use -x switch and you'll get the following prompt:
vim -x test.txt
Enter encryption key:
Enter the key twice and you will be able to edit encrypted file. If the key is incorrect, you'll be editing raw encrypted content.