Add Password Protection to a file your editing in vim.

vim -x <FILENAME>
While I love gpg and truecrypt there's some times when you just want to edit a file and not worry about keys or having to deal needing extra software on hand. Thus, you can use vim's encrypted file format. For more info on vim's encrypted files visit:
Sample Output
Enter encryption key:

By: denzuko
2009-05-05 23:24:17

What Others Think

Shouldn't that be 'vim -x '? 'vim -e' puts you into ex mode...
mayersj1 · 650 weeks and 2 days ago
from 'The normal way to work with encryption, is to use the ":X" command, which will ask you to enter a key.' Interesting and thanks, good to learn something. vote++;
mpb · 650 weeks and 2 days ago
@mayersjl thanks, I'll fix that up for everyone @mpb Glad I could help.
denzuko · 650 weeks and 2 days ago
Note that the encryption vim uses is really weak, so it is not really an alternative to gpg and the likes (this is also noted in the documentation linked). That said, it is useful for quick and dirty obfuscation :)
spatz · 650 weeks and 1 day ago
Online docs moved, now located at As noted in those docs, vim 7.3+ supports the blowfish cypher, which will give you stronger encryption (and makes the file unusable to older versions of vim). You can launch this directly from the command line with: vim -x +"set cm=blowfish" <FILENAME>
adamhotep · 496 weeks and 6 days ago
You're, not 'Your'.
vim99 · 140 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: